@ykdz/template 0.0.36 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application.d.ts +129 -13
- package/dist/application.js +286 -174
- package/dist/command-result.d.ts +9 -0
- package/dist/command-result.js +231 -0
- package/dist/main.d.ts +4 -1
- package/dist/main.js +319 -51
- package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.d.ts +122 -22
- package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.js +2081 -410
- package/node_modules/@ykdz/template-builtin-presets/dist/src/generation-record.d.ts +18 -3
- package/node_modules/@ykdz/template-builtin-presets/dist/src/generation-record.js +29 -5
- package/node_modules/@ykdz/template-builtin-presets/dist/src/index.d.ts +2 -2
- package/node_modules/@ykdz/template-builtin-presets/dist/src/index.js +1 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/rust-bin/definition.d.ts +1 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/rust-bin/definition.js +16 -15
- package/node_modules/@ykdz/template-builtin-presets/dist/src/shared/development-container.d.ts +1 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/shared/development-container.js +1 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/shared/typescript.d.ts +8 -6
- package/node_modules/@ykdz/template-builtin-presets/dist/src/shared/typescript.js +3 -3
- package/node_modules/@ykdz/template-builtin-presets/dist/src/shared/vue.d.ts +6 -4
- package/node_modules/@ykdz/template-builtin-presets/dist/src/shared/vue.js +8 -6
- package/node_modules/@ykdz/template-builtin-presets/dist/src/template-sources.d.ts +1 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/template-sources.js +1 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/ts-cli/definition.d.ts +1 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/ts-cli/definition.js +34 -8
- package/node_modules/@ykdz/template-builtin-presets/dist/src/ts-lib/definition.d.ts +1 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/ts-lib/definition.js +7 -7
- package/node_modules/@ykdz/template-builtin-presets/dist/src/vike-app/definition.d.ts +28 -2
- package/node_modules/@ykdz/template-builtin-presets/dist/src/vike-app/definition.js +164 -148
- package/node_modules/@ykdz/template-builtin-presets/dist/src/vue-app/definition.d.ts +2 -2
- package/node_modules/@ykdz/template-builtin-presets/dist/src/vue-app/definition.js +3 -3
- package/node_modules/@ykdz/template-builtin-presets/dist/src/vue-hono-app/definition.d.ts +2 -2
- package/node_modules/@ykdz/template-builtin-presets/dist/src/vue-hono-app/definition.js +22 -23
- package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/bin/semver.js +0 -0
- package/node_modules/{valibot → @ykdz/template-builtin-presets/node_modules/valibot}/README.md +1 -1
- package/node_modules/{valibot → @ykdz/template-builtin-presets/node_modules/valibot}/dist/index.cjs +427 -504
- package/node_modules/{valibot → @ykdz/template-builtin-presets/node_modules/valibot}/dist/index.d.cts +427 -32
- package/node_modules/{valibot → @ykdz/template-builtin-presets/node_modules/valibot}/dist/index.d.mts +427 -32
- package/node_modules/@ykdz/template-builtin-presets/node_modules/valibot/dist/index.min.cjs +2 -0
- package/node_modules/@ykdz/template-builtin-presets/node_modules/valibot/dist/index.min.mjs +2 -0
- package/node_modules/{valibot → @ykdz/template-builtin-presets/node_modules/valibot}/dist/index.mjs +418 -504
- package/node_modules/{valibot → @ykdz/template-builtin-presets/node_modules/valibot}/package.json +7 -2
- package/node_modules/@ykdz/template-builtin-presets/package.json +23 -10
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-deployment-diagnostics.yml +5 -5
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-deployment.yml +4 -4
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-diagnostics.yml +4 -4
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check.yml +3 -3
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/AGENTS.md.template +17 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/devcontainer.json +4 -2
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/pnpm-workspace.dynamic.txt +1 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/pnpm-workspace.yaml +5 -5
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/check-toolchain-versions.ts +556 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/tsconfig.json +4 -6
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/tsconfig.packing-hook.json +2 -3
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo.json +1 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/rust-bin/turbo.json +19 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/shared/devcontainer/node-pnpm.Dockerfile +4 -6
- package/node_modules/@ykdz/template-builtin-presets/templates/shared/oxc/tsconfig.config.json +2 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/tsconfig.app.json +1 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/tsconfig.node.json +2 -2
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/readiness.ts +26 -5
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/release.yml +1 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/root-tsconfig.json +2 -7
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/tsconfig.json +2 -2
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-lib/tsconfig.build.json +2 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-lib/tsconfig.json +2 -2
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/scripts/reset.ts +3 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/src/db.ts +3 -4
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/src/readiness.ts +6 -5
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/src/storage.ts +93 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/tsconfig.build.json +8 -2
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/tsconfig.json +3 -7
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/turbo.json +1 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db-migrations/drizzle.config.ts +5 -5
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db-migrations/tsconfig.build.json +2 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db-migrations/tsconfig.json +2 -2
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/.env.example +2 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/Dockerfile +25 -17
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/Dockerfile.dockerignore +4 -4
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/playwright.config.ts +5 -25
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/scripts/check-standalone-deployment.ts +17 -15
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/test/playwright-teardown.ts +6 -7
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/tsconfig.app.json +1 -2
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/tsconfig.json +0 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/tsconfig.node.json +2 -3
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/tsconfig.test.json +0 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/turbo.json +0 -8
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/vite.config.ts +3 -39
- package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/api/tsconfig.json +7 -2
- package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/root/playwright.config.ts +34 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/{web → root}/test/e2e/app.spec.ts +3 -3
- package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/root/test/e2e/fixtures.ts +15 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/root/tsconfig.json +3 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/src/api.ts +1 -3
- package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/turbo.json +0 -4
- package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/vite.config.ts +2 -0
- package/node_modules/@ykdz/template-core/dist/ci-diagnostic-artifact.d.ts +2 -2
- package/node_modules/@ykdz/template-core/dist/ci-diagnostic-artifact.js +10 -5
- package/node_modules/@ykdz/template-core/dist/module-graph.d.ts +1 -1
- package/node_modules/@ykdz/template-core/dist/module-graph.js +7 -5
- package/node_modules/@ykdz/template-core/dist/package-contribution.d.ts +33 -10
- package/node_modules/@ykdz/template-core/dist/package-contribution.js +1 -1
- package/node_modules/@ykdz/template-core/dist/pnpm-workspace.yaml +10 -9
- package/node_modules/@ykdz/template-core/dist/preset-definition.d.ts +11 -0
- package/node_modules/@ykdz/template-core/dist/project-github.d.ts +7 -5
- package/node_modules/@ykdz/template-core/dist/project-github.js +4 -4
- package/node_modules/@ykdz/template-core/dist/project-linking-v2.d.ts +2 -2
- package/node_modules/@ykdz/template-core/dist/project-linking-v2.js +12 -6
- package/node_modules/@ykdz/template-core/dist/project-projection.d.ts +27 -0
- package/node_modules/@ykdz/template-core/dist/project-projection.js +394 -9
- package/node_modules/@ykdz/template-core/dist/release-toolchain-snapshot.d.ts +10 -0
- package/node_modules/@ykdz/template-core/dist/release-toolchain-snapshot.js +9 -0
- package/node_modules/@ykdz/template-core/dist/template-boundary-check.js +15 -9
- package/node_modules/@ykdz/template-core/node_modules/valibot/LICENSE.md +9 -0
- package/node_modules/@ykdz/template-core/node_modules/valibot/README.md +94 -0
- package/node_modules/@ykdz/template-core/node_modules/valibot/dist/index.cjs +7897 -0
- package/node_modules/@ykdz/template-core/node_modules/valibot/dist/index.d.cts +16579 -0
- package/node_modules/@ykdz/template-core/node_modules/valibot/dist/index.d.mts +16579 -0
- package/node_modules/@ykdz/template-core/node_modules/valibot/dist/index.min.cjs +2 -0
- package/node_modules/@ykdz/template-core/node_modules/valibot/dist/index.min.mjs +2 -0
- package/node_modules/@ykdz/template-core/node_modules/valibot/dist/index.mjs +7577 -0
- package/node_modules/@ykdz/template-core/node_modules/valibot/package.json +84 -0
- package/node_modules/@ykdz/template-core/package.json +0 -2
- package/node_modules/hosted-git-info/LICENSE +13 -0
- package/node_modules/hosted-git-info/README.md +138 -0
- package/node_modules/hosted-git-info/lib/from-url.js +122 -0
- package/node_modules/hosted-git-info/lib/hosts.js +229 -0
- package/node_modules/hosted-git-info/lib/index.js +227 -0
- package/node_modules/hosted-git-info/lib/parse-url.js +79 -0
- package/node_modules/hosted-git-info/package.json +57 -0
- package/node_modules/jsonc-parser/CHANGELOG.md +76 -0
- package/node_modules/jsonc-parser/LICENSE.md +21 -0
- package/node_modules/jsonc-parser/README.md +364 -0
- package/node_modules/jsonc-parser/SECURITY.md +41 -0
- package/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
- package/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
- package/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
- package/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
- package/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
- package/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
- package/node_modules/jsonc-parser/lib/esm/main.js +178 -0
- package/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
- package/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
- package/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
- package/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
- package/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
- package/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
- package/node_modules/jsonc-parser/lib/umd/main.js +194 -0
- package/node_modules/jsonc-parser/package.json +37 -0
- package/node_modules/lru-cache/LICENSE.md +55 -0
- package/node_modules/lru-cache/README.md +469 -0
- package/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.d.ts +5 -0
- package/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.js +7 -0
- package/node_modules/lru-cache/dist/commonjs/browser/index.d.ts +1400 -0
- package/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/browser/index.js +1733 -0
- package/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/browser/index.min.js +2 -0
- package/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +7 -0
- package/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts +12 -0
- package/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/browser/perf.js +10 -0
- package/node_modules/lru-cache/dist/commonjs/browser/perf.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.cjs.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.d.cts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts +5 -0
- package/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +7 -0
- package/node_modules/lru-cache/dist/commonjs/index.d.ts +1400 -0
- package/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/index.js +1733 -0
- package/node_modules/lru-cache/dist/commonjs/index.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
- package/node_modules/lru-cache/dist/commonjs/index.min.js.map +7 -0
- package/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.d.ts +5 -0
- package/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.js +9 -0
- package/node_modules/lru-cache/dist/commonjs/node/index.d.ts +1400 -0
- package/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/node/index.js +1733 -0
- package/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/node/index.min.js +2 -0
- package/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +7 -0
- package/node_modules/lru-cache/dist/commonjs/node/perf.d.ts +12 -0
- package/node_modules/lru-cache/dist/commonjs/node/perf.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/node/perf.js +10 -0
- package/node_modules/lru-cache/dist/commonjs/node/perf.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/package.json +3 -0
- package/node_modules/lru-cache/dist/commonjs/perf.d.ts +12 -0
- package/node_modules/lru-cache/dist/commonjs/perf.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/perf.js +10 -0
- package/node_modules/lru-cache/dist/commonjs/perf.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel-react-native.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel-react-native.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel.d.ts +5 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel.js +7 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/index.d.ts +1400 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/index.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/index.js +1733 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/index.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/perf.d.ts +12 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/perf.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/perf.js +10 -0
- package/node_modules/lru-cache/dist/commonjs/react-native/perf.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.d.ts +5 -0
- package/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
- package/node_modules/lru-cache/dist/esm/browser/index.d.ts +1400 -0
- package/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/browser/index.js +1729 -0
- package/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
- package/node_modules/lru-cache/dist/esm/browser/index.min.js.map +7 -0
- package/node_modules/lru-cache/dist/esm/browser/perf.d.ts +12 -0
- package/node_modules/lru-cache/dist/esm/browser/perf.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/browser/perf.js +7 -0
- package/node_modules/lru-cache/dist/esm/browser/perf.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.d.mts.map +1 -0
- package/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.mjs.map +1 -0
- package/node_modules/lru-cache/dist/esm/diagnostics-channel.d.ts +5 -0
- package/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
- package/node_modules/lru-cache/dist/esm/index.d.ts +1400 -0
- package/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/index.js +1729 -0
- package/node_modules/lru-cache/dist/esm/index.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/index.min.js +2 -0
- package/node_modules/lru-cache/dist/esm/index.min.js.map +7 -0
- package/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/node/diagnostics-channel.d.ts +5 -0
- package/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +6 -0
- package/node_modules/lru-cache/dist/esm/node/index.d.ts +1400 -0
- package/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/node/index.js +1729 -0
- package/node_modules/lru-cache/dist/esm/node/index.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
- package/node_modules/lru-cache/dist/esm/node/index.min.js.map +7 -0
- package/node_modules/lru-cache/dist/esm/node/perf.d.ts +12 -0
- package/node_modules/lru-cache/dist/esm/node/perf.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/node/perf.js +7 -0
- package/node_modules/lru-cache/dist/esm/node/perf.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/package.json +3 -0
- package/node_modules/lru-cache/dist/esm/perf.d.ts +12 -0
- package/node_modules/lru-cache/dist/esm/perf.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/perf.js +7 -0
- package/node_modules/lru-cache/dist/esm/perf.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel-react-native.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel-react-native.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel.d.ts +5 -0
- package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel.js +4 -0
- package/node_modules/lru-cache/dist/esm/react-native/index.d.ts +1400 -0
- package/node_modules/lru-cache/dist/esm/react-native/index.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/react-native/index.js +1729 -0
- package/node_modules/lru-cache/dist/esm/react-native/index.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/react-native/perf.d.ts +12 -0
- package/node_modules/lru-cache/dist/esm/react-native/perf.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/react-native/perf.js +7 -0
- package/node_modules/lru-cache/dist/esm/react-native/perf.js.map +1 -0
- package/node_modules/lru-cache/package.json +180 -0
- package/node_modules/npm-package-arg/LICENSE +15 -0
- package/node_modules/npm-package-arg/README.md +104 -0
- package/node_modules/npm-package-arg/lib/npa.js +479 -0
- package/node_modules/npm-package-arg/node_modules/semver/LICENSE +15 -0
- package/node_modules/npm-package-arg/node_modules/semver/README.md +680 -0
- package/node_modules/npm-package-arg/node_modules/semver/bin/semver.js +195 -0
- package/node_modules/npm-package-arg/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/npm-package-arg/node_modules/semver/classes/index.js +7 -0
- package/node_modules/npm-package-arg/node_modules/semver/classes/range.js +577 -0
- package/node_modules/npm-package-arg/node_modules/semver/classes/semver.js +350 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/major.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/npm-package-arg/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/npm-package-arg/node_modules/semver/index.js +93 -0
- package/node_modules/npm-package-arg/node_modules/semver/internal/constants.js +37 -0
- package/node_modules/npm-package-arg/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/npm-package-arg/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/npm-package-arg/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/npm-package-arg/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/npm-package-arg/node_modules/semver/internal/re.js +223 -0
- package/node_modules/npm-package-arg/node_modules/semver/package.json +78 -0
- package/node_modules/npm-package-arg/node_modules/semver/preload.js +4 -0
- package/node_modules/npm-package-arg/node_modules/semver/range.bnf +17 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/npm-package-arg/node_modules/semver/ranges/valid.js +13 -0
- package/node_modules/npm-package-arg/package.json +60 -0
- package/node_modules/picomatch/LICENSE +21 -0
- package/node_modules/picomatch/README.md +743 -0
- package/node_modules/picomatch/index.js +17 -0
- package/node_modules/picomatch/lib/constants.js +184 -0
- package/node_modules/picomatch/lib/parse.js +1425 -0
- package/node_modules/picomatch/lib/picomatch.js +361 -0
- package/node_modules/picomatch/lib/scan.js +403 -0
- package/node_modules/picomatch/lib/utils.js +72 -0
- package/node_modules/picomatch/package.json +83 -0
- package/node_modules/picomatch/posix.js +3 -0
- package/node_modules/proc-log/LICENSE +15 -0
- package/node_modules/proc-log/README.md +226 -0
- package/node_modules/proc-log/lib/index.js +158 -0
- package/node_modules/proc-log/package.json +46 -0
- package/node_modules/smol-toml/LICENSE +24 -0
- package/node_modules/smol-toml/README.md +605 -0
- package/node_modules/smol-toml/dist/date.d.ts +41 -0
- package/node_modules/smol-toml/dist/date.js +156 -0
- package/node_modules/smol-toml/dist/error.d.ts +37 -0
- package/node_modules/smol-toml/dist/error.js +67 -0
- package/node_modules/smol-toml/dist/extract.js +289 -0
- package/node_modules/smol-toml/dist/index.cjs +770 -0
- package/node_modules/smol-toml/dist/index.d.ts +44 -0
- package/node_modules/smol-toml/dist/index.js +34 -0
- package/node_modules/smol-toml/dist/parse.d.ts +73 -0
- package/node_modules/smol-toml/dist/parse.js +164 -0
- package/node_modules/smol-toml/dist/primitive.js +151 -0
- package/node_modules/smol-toml/dist/stringify.d.ts +32 -0
- package/node_modules/smol-toml/dist/stringify.js +219 -0
- package/node_modules/smol-toml/dist/struct.js +156 -0
- package/node_modules/smol-toml/dist/util.d.ts +43 -0
- package/node_modules/smol-toml/dist/util.js +57 -0
- package/node_modules/smol-toml/package.json +68 -0
- package/node_modules/typescript/bin/tsc +0 -0
- package/node_modules/typescript/bin/tsserver +0 -0
- package/node_modules/unbash/LICENSE +15 -0
- package/node_modules/unbash/README.md +289 -0
- package/node_modules/unbash/dist/ansi-c.d.ts +5 -0
- package/node_modules/unbash/dist/ansi-c.js +130 -0
- package/node_modules/unbash/dist/arithmetic.d.ts +11 -0
- package/node_modules/unbash/dist/arithmetic.js +530 -0
- package/node_modules/unbash/dist/assignment.d.ts +15 -0
- package/node_modules/unbash/dist/assignment.js +118 -0
- package/node_modules/unbash/dist/chars.d.ts +41 -0
- package/node_modules/unbash/dist/chars.js +41 -0
- package/node_modules/unbash/dist/command.d.ts +14 -0
- package/node_modules/unbash/dist/command.js +41 -0
- package/node_modules/unbash/dist/heredoc.d.ts +18 -0
- package/node_modules/unbash/dist/heredoc.js +25 -0
- package/node_modules/unbash/dist/internal-types.d.ts +87 -0
- package/node_modules/unbash/dist/internal-types.js +1 -0
- package/node_modules/unbash/dist/lexer.d.ts +202 -0
- package/node_modules/unbash/dist/lexer.js +3930 -0
- package/node_modules/unbash/dist/parser.d.ts +4 -0
- package/node_modules/unbash/dist/parser.js +1295 -0
- package/node_modules/unbash/dist/parts.d.ts +17 -0
- package/node_modules/unbash/dist/parts.js +82 -0
- package/node_modules/unbash/dist/printer.d.ts +2 -0
- package/node_modules/unbash/dist/printer.js +536 -0
- package/node_modules/unbash/dist/types.d.ts +494 -0
- package/node_modules/unbash/dist/types.js +1 -0
- package/node_modules/unbash/dist/word.d.ts +22 -0
- package/node_modules/unbash/dist/word.js +102 -0
- package/node_modules/unbash/package.json +80 -0
- package/node_modules/validate-npm-package-name/LICENSE +6 -0
- package/node_modules/validate-npm-package-name/README.md +120 -0
- package/node_modules/validate-npm-package-name/lib/builtin-modules.json +1 -0
- package/node_modules/validate-npm-package-name/lib/index.js +114 -0
- package/node_modules/validate-npm-package-name/package.json +59 -0
- package/node_modules/yaml/LICENSE +13 -0
- package/node_modules/yaml/README.md +172 -0
- package/node_modules/yaml/bin.mjs +11 -0
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
- package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
- package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
- package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +226 -0
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
- package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
- package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
- package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
- package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
- package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
- package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
- package/node_modules/yaml/browser/dist/errors.js +57 -0
- package/node_modules/yaml/browser/dist/index.js +17 -0
- package/node_modules/yaml/browser/dist/log.js +11 -0
- package/node_modules/yaml/browser/dist/nodes/Alias.js +118 -0
- package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
- package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
- package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
- package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
- package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
- package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
- package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
- package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
- package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
- package/node_modules/yaml/browser/dist/public-api.js +102 -0
- package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
- package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
- package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
- package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
- package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
- package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
- package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
- package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
- package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
- package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
- package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
- package/node_modules/yaml/browser/dist/util.js +11 -0
- package/node_modules/yaml/browser/dist/visit.js +233 -0
- package/node_modules/yaml/browser/index.js +5 -0
- package/node_modules/yaml/browser/package.json +3 -0
- package/node_modules/yaml/dist/cli.d.ts +8 -0
- package/node_modules/yaml/dist/cli.mjs +201 -0
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
- package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
- package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
- package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
- package/node_modules/yaml/dist/compose/compose-node.js +112 -0
- package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
- package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
- package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
- package/node_modules/yaml/dist/compose/composer.js +224 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
- package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +228 -0
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
- package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
- package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
- package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
- package/node_modules/yaml/dist/doc/Document.js +337 -0
- package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
- package/node_modules/yaml/dist/doc/anchors.js +76 -0
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
- package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
- package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
- package/node_modules/yaml/dist/doc/createNode.js +90 -0
- package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
- package/node_modules/yaml/dist/doc/directives.js +178 -0
- package/node_modules/yaml/dist/errors.d.ts +21 -0
- package/node_modules/yaml/dist/errors.js +62 -0
- package/node_modules/yaml/dist/index.d.ts +25 -0
- package/node_modules/yaml/dist/index.js +50 -0
- package/node_modules/yaml/dist/log.d.ts +3 -0
- package/node_modules/yaml/dist/log.js +19 -0
- package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/Alias.js +120 -0
- package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
- package/node_modules/yaml/dist/nodes/Collection.js +151 -0
- package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/Node.js +40 -0
- package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
- package/node_modules/yaml/dist/nodes/Pair.js +39 -0
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
- package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
- package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
- package/node_modules/yaml/dist/nodes/identity.js +53 -0
- package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/toJS.js +39 -0
- package/node_modules/yaml/dist/options.d.ts +350 -0
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
- package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
- package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
- package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
- package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
- package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
- package/node_modules/yaml/dist/parse/cst.js +112 -0
- package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
- package/node_modules/yaml/dist/parse/lexer.js +723 -0
- package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
- package/node_modules/yaml/dist/parse/line-counter.js +41 -0
- package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
- package/node_modules/yaml/dist/parse/parser.js +980 -0
- package/node_modules/yaml/dist/public-api.d.ts +44 -0
- package/node_modules/yaml/dist/public-api.js +107 -0
- package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
- package/node_modules/yaml/dist/schema/Schema.js +39 -0
- package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/map.js +19 -0
- package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
- package/node_modules/yaml/dist/schema/common/null.js +17 -0
- package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/seq.js +19 -0
- package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/string.js +16 -0
- package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/bool.js +21 -0
- package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/float.js +47 -0
- package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/int.js +42 -0
- package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/core/schema.js +25 -0
- package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
- package/node_modules/yaml/dist/schema/json/schema.js +64 -0
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
- package/node_modules/yaml/dist/schema/tags.js +99 -0
- package/node_modules/yaml/dist/schema/types.d.ts +92 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
- package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
- package/node_modules/yaml/dist/stringify/stringify.js +132 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
- package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
- package/node_modules/yaml/dist/test-events.d.ts +4 -0
- package/node_modules/yaml/dist/test-events.js +134 -0
- package/node_modules/yaml/dist/util.d.ts +16 -0
- package/node_modules/yaml/dist/util.js +28 -0
- package/node_modules/yaml/dist/visit.d.ts +102 -0
- package/node_modules/yaml/dist/visit.js +236 -0
- package/node_modules/yaml/package.json +97 -0
- package/node_modules/yaml/util.js +2 -0
- package/package.json +21 -19
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/check-boundaries.ts +0 -12
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/run-root-owned-task.ts +0 -69
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/test/global-setup.ts +0 -21
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/vitest.config.ts +0 -7
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/devcontainer/docker-client.Dockerfile +0 -3
- package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/playwright.config.ts +0 -90
- package/node_modules/@ykdz/template-core/dist/toolchain-baseline-update.d.ts +0 -45
- package/node_modules/@ykdz/template-core/dist/toolchain-baseline-update.js +0 -27
- package/node_modules/@ykdz/template-core/dist/toolchain-resolution.d.ts +0 -37
- package/node_modules/@ykdz/template-core/dist/toolchain-resolution.js +0 -195
- package/node_modules/valibot/dist/index.min.cjs +0 -2
- package/node_modules/valibot/dist/index.min.mjs +0 -2
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/LICENSE +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/README.md +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/classes/comparator.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/classes/index.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/classes/range.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/classes/semver.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/clean.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/cmp.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/coerce.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/compare-build.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/compare-loose.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/compare.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/diff.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/eq.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/gt.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/gte.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/inc.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/lt.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/lte.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/major.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/minor.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/neq.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/parse.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/patch.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/prerelease.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/rcompare.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/rsort.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/satisfies.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/sort.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/truncate.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/functions/valid.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/index.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/internal/constants.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/internal/debug.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/internal/identifiers.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/internal/lrucache.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/internal/parse-options.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/internal/re.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/package.json +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/preload.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/range.bnf +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/gtr.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/intersects.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/ltr.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/max-satisfying.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/min-satisfying.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/min-version.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/outside.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/simplify.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/subset.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/to-comparators.js +0 -0
- /package/node_modules/{semver → @ykdz/template-builtin-presets/node_modules/semver}/ranges/valid.js +0 -0
- /package/node_modules/{valibot → @ykdz/template-builtin-presets/node_modules/valibot}/LICENSE.md +0 -0
- /package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/src/{types.d.ts → types.ts} +0 -0
|
@@ -0,0 +1,1295 @@
|
|
|
1
|
+
import { hasEmbeddedWordStructure, LexContext, MAX_SYNTAX_NESTING, Token, Lexer, TokenValue } from "./lexer.js";
|
|
2
|
+
import { parseArithmeticExpression } from "./arithmetic.js";
|
|
3
|
+
import { computeWordParts, computeEmbeddedWordParts, computeHereDocBodyParts } from "./parts.js";
|
|
4
|
+
import { WordImpl } from "./word.js";
|
|
5
|
+
import { AssignmentImpl } from "./assignment.js";
|
|
6
|
+
import { CommandImpl } from "./command.js";
|
|
7
|
+
import { HereDocBodyImpl } from "./heredoc.js";
|
|
8
|
+
WordImpl._resolveWord = computeWordParts;
|
|
9
|
+
HereDocBodyImpl._resolveParts = computeHereDocBodyParts;
|
|
10
|
+
function isDeclarationCommand(name) {
|
|
11
|
+
switch (name.length) {
|
|
12
|
+
case 5:
|
|
13
|
+
return name === "local" || name === "alias";
|
|
14
|
+
case 6:
|
|
15
|
+
return name === "export";
|
|
16
|
+
case 7:
|
|
17
|
+
return name === "declare" || name === "typeset";
|
|
18
|
+
case 8:
|
|
19
|
+
return name === "readonly";
|
|
20
|
+
default:
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class ArithmeticCommandImpl {
|
|
25
|
+
type = "ArithmeticCommand";
|
|
26
|
+
pos;
|
|
27
|
+
end;
|
|
28
|
+
body;
|
|
29
|
+
#source;
|
|
30
|
+
#depth;
|
|
31
|
+
#expression = null;
|
|
32
|
+
constructor(pos, end, body, source, depth) {
|
|
33
|
+
this.pos = pos;
|
|
34
|
+
this.end = end;
|
|
35
|
+
this.body = body;
|
|
36
|
+
this.#source = source;
|
|
37
|
+
this.#depth = depth;
|
|
38
|
+
}
|
|
39
|
+
get expression() {
|
|
40
|
+
if (this.#expression === null) {
|
|
41
|
+
this.#expression = parseArithmeticWithParts(this.body, this.pos + 2, this.#source, this.#depth);
|
|
42
|
+
}
|
|
43
|
+
return this.#expression;
|
|
44
|
+
}
|
|
45
|
+
set expression(v) {
|
|
46
|
+
this.#expression = v ?? undefined;
|
|
47
|
+
}
|
|
48
|
+
toJSON() {
|
|
49
|
+
return {
|
|
50
|
+
type: this.type,
|
|
51
|
+
pos: this.pos,
|
|
52
|
+
end: this.end,
|
|
53
|
+
expression: this.expression,
|
|
54
|
+
body: this.body,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
class ArithmeticForImpl {
|
|
59
|
+
type = "ArithmeticFor";
|
|
60
|
+
pos;
|
|
61
|
+
end;
|
|
62
|
+
body;
|
|
63
|
+
#initStr;
|
|
64
|
+
#testStr;
|
|
65
|
+
#updateStr;
|
|
66
|
+
#initPos;
|
|
67
|
+
#testPos;
|
|
68
|
+
#updatePos;
|
|
69
|
+
#source;
|
|
70
|
+
#depth;
|
|
71
|
+
#initialize = null;
|
|
72
|
+
#test = null;
|
|
73
|
+
#update = null;
|
|
74
|
+
constructor(pos, end, body, initStr, testStr, updateStr, initPos, testPos, updatePos, source, depth) {
|
|
75
|
+
this.pos = pos;
|
|
76
|
+
this.end = end;
|
|
77
|
+
this.body = body;
|
|
78
|
+
this.#initStr = initStr;
|
|
79
|
+
this.#testStr = testStr;
|
|
80
|
+
this.#updateStr = updateStr;
|
|
81
|
+
this.#initPos = initPos;
|
|
82
|
+
this.#testPos = testPos;
|
|
83
|
+
this.#updatePos = updatePos;
|
|
84
|
+
this.#source = source;
|
|
85
|
+
this.#depth = depth;
|
|
86
|
+
}
|
|
87
|
+
get initialize() {
|
|
88
|
+
if (this.#initialize === null) {
|
|
89
|
+
if (this.#initStr) {
|
|
90
|
+
this.#initialize = parseArithmeticWithParts(this.#initStr, this.#initPos, this.#source, this.#depth);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.#initialize = undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return this.#initialize;
|
|
97
|
+
}
|
|
98
|
+
set initialize(v) {
|
|
99
|
+
this.#initialize = v ?? undefined;
|
|
100
|
+
}
|
|
101
|
+
get test() {
|
|
102
|
+
if (this.#test === null) {
|
|
103
|
+
if (this.#testStr) {
|
|
104
|
+
this.#test = parseArithmeticWithParts(this.#testStr, this.#testPos, this.#source, this.#depth);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.#test = undefined;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return this.#test;
|
|
111
|
+
}
|
|
112
|
+
set test(v) {
|
|
113
|
+
this.#test = v ?? undefined;
|
|
114
|
+
}
|
|
115
|
+
get update() {
|
|
116
|
+
if (this.#update === null) {
|
|
117
|
+
if (this.#updateStr) {
|
|
118
|
+
this.#update = parseArithmeticWithParts(this.#updateStr, this.#updatePos, this.#source, this.#depth);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.#update = undefined;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return this.#update;
|
|
125
|
+
}
|
|
126
|
+
set update(v) {
|
|
127
|
+
this.#update = v ?? undefined;
|
|
128
|
+
}
|
|
129
|
+
toJSON() {
|
|
130
|
+
return {
|
|
131
|
+
type: this.type,
|
|
132
|
+
pos: this.pos,
|
|
133
|
+
end: this.end,
|
|
134
|
+
initialize: this.initialize,
|
|
135
|
+
test: this.test,
|
|
136
|
+
update: this.update,
|
|
137
|
+
body: this.body,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const CASE_TERMINATORS = {
|
|
142
|
+
[Token.DoubleSemi]: ";;",
|
|
143
|
+
[Token.SemiAmp]: ";&",
|
|
144
|
+
[Token.DoubleSemiAmp]: ";;&",
|
|
145
|
+
};
|
|
146
|
+
const REDIRECT_OPS = {
|
|
147
|
+
">": ">",
|
|
148
|
+
">>": ">>",
|
|
149
|
+
"<": "<",
|
|
150
|
+
"<>": "<>",
|
|
151
|
+
"<&": "<&",
|
|
152
|
+
">&": ">&",
|
|
153
|
+
">|": ">|",
|
|
154
|
+
"&>": "&>",
|
|
155
|
+
"&>>": "&>>",
|
|
156
|
+
};
|
|
157
|
+
function parseArithmeticWithParts(body, offset, source, depth = 0) {
|
|
158
|
+
if (!hasEmbeddedWordStructure(source, offset, offset + body.length)) {
|
|
159
|
+
return parseArithmeticExpression(body, offset) ?? undefined;
|
|
160
|
+
}
|
|
161
|
+
const commandExpansions = [];
|
|
162
|
+
const embeddedWords = [];
|
|
163
|
+
const lexer = new Lexer(source);
|
|
164
|
+
const expression = parseArithmeticExpression(body, offset, {
|
|
165
|
+
commandExpansions,
|
|
166
|
+
embeddedWords,
|
|
167
|
+
findClosingBracket: (start, end) => lexer.findClosingBracket(start, end),
|
|
168
|
+
findClosingBrace: (start, end) => lexer.findClosingBrace(start, end),
|
|
169
|
+
findClosingParenthesis: (start, end) => lexer.findClosingParenthesis(start, end),
|
|
170
|
+
findArithmeticExpansionEnd: (start, end) => lexer.findArithmeticExpansionEnd(start, end),
|
|
171
|
+
findArithmeticWordEnd: (start, end) => lexer.findArithmeticWordEnd(start, end),
|
|
172
|
+
}) ?? undefined;
|
|
173
|
+
for (const node of commandExpansions) {
|
|
174
|
+
if (depth <= MAX_SYNTAX_NESTING) {
|
|
175
|
+
node.script = parseRegion(source, node.pos + 2, node.end - 1, depth + 1, true);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
for (const node of embeddedWords)
|
|
179
|
+
node.parts = computeEmbeddedWordParts(source, node, depth);
|
|
180
|
+
return expression;
|
|
181
|
+
}
|
|
182
|
+
// Lookup tables for O(1) token classification (replaces sequential comparisons)
|
|
183
|
+
const listTerminators = new Uint8Array(37);
|
|
184
|
+
listTerminators[Token.EOF] = 1;
|
|
185
|
+
listTerminators[Token.RParen] = 1;
|
|
186
|
+
listTerminators[Token.RBrace] = 1;
|
|
187
|
+
listTerminators[Token.Then] = 1;
|
|
188
|
+
listTerminators[Token.Else] = 1;
|
|
189
|
+
listTerminators[Token.Elif] = 1;
|
|
190
|
+
listTerminators[Token.Fi] = 1;
|
|
191
|
+
listTerminators[Token.Do] = 1;
|
|
192
|
+
listTerminators[Token.Done] = 1;
|
|
193
|
+
listTerminators[Token.Esac] = 1;
|
|
194
|
+
listTerminators[Token.DoubleSemi] = 1;
|
|
195
|
+
listTerminators[Token.SemiAmp] = 1;
|
|
196
|
+
listTerminators[Token.DoubleSemiAmp] = 1;
|
|
197
|
+
// After one of these Bash is at a command-start position, the only place a reserved-word
|
|
198
|
+
// terminator may follow with no separator.
|
|
199
|
+
const compoundClosers = new Uint8Array(37);
|
|
200
|
+
compoundClosers[Token.RParen] = 1;
|
|
201
|
+
compoundClosers[Token.RBrace] = 1;
|
|
202
|
+
compoundClosers[Token.DblRBracket] = 1;
|
|
203
|
+
compoundClosers[Token.Fi] = 1;
|
|
204
|
+
compoundClosers[Token.Done] = 1;
|
|
205
|
+
compoundClosers[Token.Esac] = 1;
|
|
206
|
+
compoundClosers[Token.ArithCmd] = 1;
|
|
207
|
+
// Inside `[[ ]]` only an unquoted `!` negates; `'!'` and `\!` are ordinary operands.
|
|
208
|
+
function isTestNegation(t) {
|
|
209
|
+
return t.token === Token.Word && t.keywordEligible && t.value === "!";
|
|
210
|
+
}
|
|
211
|
+
const commandStarts = new Uint8Array(37);
|
|
212
|
+
commandStarts[Token.Word] = 1;
|
|
213
|
+
commandStarts[Token.Assignment] = 1;
|
|
214
|
+
commandStarts[Token.Bang] = 1;
|
|
215
|
+
commandStarts[Token.LParen] = 1;
|
|
216
|
+
commandStarts[Token.LBrace] = 1;
|
|
217
|
+
commandStarts[Token.DblLBracket] = 1;
|
|
218
|
+
commandStarts[Token.If] = 1;
|
|
219
|
+
commandStarts[Token.For] = 1;
|
|
220
|
+
commandStarts[Token.While] = 1;
|
|
221
|
+
commandStarts[Token.Until] = 1;
|
|
222
|
+
commandStarts[Token.Case] = 1;
|
|
223
|
+
commandStarts[Token.Function] = 1;
|
|
224
|
+
commandStarts[Token.Select] = 1;
|
|
225
|
+
commandStarts[Token.ArithCmd] = 1;
|
|
226
|
+
commandStarts[Token.Coproc] = 1;
|
|
227
|
+
commandStarts[Token.Redirect] = 1;
|
|
228
|
+
const UNARY_TEST_OPS = {
|
|
229
|
+
"-a": 1,
|
|
230
|
+
"-b": 1,
|
|
231
|
+
"-c": 1,
|
|
232
|
+
"-d": 1,
|
|
233
|
+
"-e": 1,
|
|
234
|
+
"-f": 1,
|
|
235
|
+
"-g": 1,
|
|
236
|
+
"-h": 1,
|
|
237
|
+
"-k": 1,
|
|
238
|
+
"-p": 1,
|
|
239
|
+
"-r": 1,
|
|
240
|
+
"-s": 1,
|
|
241
|
+
"-t": 1,
|
|
242
|
+
"-u": 1,
|
|
243
|
+
"-v": 1,
|
|
244
|
+
"-w": 1,
|
|
245
|
+
"-x": 1,
|
|
246
|
+
"-z": 1,
|
|
247
|
+
"-n": 1,
|
|
248
|
+
"-o": 1,
|
|
249
|
+
"-N": 1,
|
|
250
|
+
"-S": 1,
|
|
251
|
+
"-L": 1,
|
|
252
|
+
"-G": 1,
|
|
253
|
+
"-O": 1,
|
|
254
|
+
"-R": 1,
|
|
255
|
+
};
|
|
256
|
+
const BINARY_TEST_OPS = {
|
|
257
|
+
"==": 1,
|
|
258
|
+
"!=": 1,
|
|
259
|
+
"=~": 1,
|
|
260
|
+
"=": 1,
|
|
261
|
+
"-eq": 1,
|
|
262
|
+
"-ne": 1,
|
|
263
|
+
"-lt": 1,
|
|
264
|
+
"-le": 1,
|
|
265
|
+
"-gt": 1,
|
|
266
|
+
"-ge": 1,
|
|
267
|
+
"-nt": 1,
|
|
268
|
+
"-ot": 1,
|
|
269
|
+
"-ef": 1,
|
|
270
|
+
"<": 1,
|
|
271
|
+
">": 1,
|
|
272
|
+
};
|
|
273
|
+
const EMPTY_REDIRECTS = [];
|
|
274
|
+
export function parse(source) {
|
|
275
|
+
return new Parser(source, 0, source.length).run();
|
|
276
|
+
}
|
|
277
|
+
// Parse a [start, end) window of `source` in place, so the resulting nodes index the original
|
|
278
|
+
// source directly. Used to resolve substitution scripts with absolute offsets; not public API.
|
|
279
|
+
export function parseRegion(source, start, end, depth = 0, parenBoundary = false) {
|
|
280
|
+
return new Parser(source, start, end, depth, parenBoundary).run();
|
|
281
|
+
}
|
|
282
|
+
class Parser {
|
|
283
|
+
tok;
|
|
284
|
+
source;
|
|
285
|
+
start;
|
|
286
|
+
end;
|
|
287
|
+
depth;
|
|
288
|
+
errors = null;
|
|
289
|
+
syntaxDepth = 0;
|
|
290
|
+
// `depth` counts the substitution scripts (and sub-fields) enclosing this region; it
|
|
291
|
+
// shares the MAX_SYNTAX_NESTING budget with the lexer's lazy word-part materialization.
|
|
292
|
+
constructor(source, start, end, depth = 0, parenBoundary = false) {
|
|
293
|
+
this.tok = new Lexer(source, start, end, parenBoundary);
|
|
294
|
+
this.tok._nestingDepth = depth;
|
|
295
|
+
this.source = source;
|
|
296
|
+
this.start = start;
|
|
297
|
+
this.end = end;
|
|
298
|
+
this.depth = depth;
|
|
299
|
+
}
|
|
300
|
+
run() {
|
|
301
|
+
const start = this.start;
|
|
302
|
+
// The boundary script one level past the budget still parses (one level is cheap and
|
|
303
|
+
// iterative) but is flagged: everything below it stays unresolved.
|
|
304
|
+
if (this.depth > MAX_SYNTAX_NESTING)
|
|
305
|
+
this.error("maximum substitution nesting depth exceeded", start);
|
|
306
|
+
let shebang;
|
|
307
|
+
if (start === 0 && this.source.charCodeAt(0) === 35 && this.source.charCodeAt(1) === 33) {
|
|
308
|
+
const nl = this.source.indexOf("\n");
|
|
309
|
+
shebang = nl === -1 ? this.source : this.source.slice(0, nl);
|
|
310
|
+
}
|
|
311
|
+
const commands = this.list();
|
|
312
|
+
for (;;) {
|
|
313
|
+
const unexpected = this.tok.peek(LexContext.CommandStart);
|
|
314
|
+
if (unexpected.token === Token.EOF)
|
|
315
|
+
break;
|
|
316
|
+
this.error(`unexpected token '${unexpected.value}'`, unexpected.pos);
|
|
317
|
+
// `In` cannot join `listTerminators`: `list()` shares it, and `in` must not terminate a
|
|
318
|
+
// list inside `for`/`case`.
|
|
319
|
+
if (!listTerminators[unexpected.token] && unexpected.token !== Token.In)
|
|
320
|
+
break;
|
|
321
|
+
this.tok.next(LexContext.CommandStart);
|
|
322
|
+
let separator = this.tok.peek(LexContext.CommandStart).token;
|
|
323
|
+
if (separator !== Token.Semi && separator !== Token.Newline && separator !== Token.Amp)
|
|
324
|
+
break;
|
|
325
|
+
while (separator === Token.Semi || separator === Token.Newline || separator === Token.Amp) {
|
|
326
|
+
this.tok.next(LexContext.CommandStart);
|
|
327
|
+
separator = this.tok.peek(LexContext.CommandStart).token;
|
|
328
|
+
}
|
|
329
|
+
const recovered = this.list();
|
|
330
|
+
for (let i = 0; i < recovered.length; i++)
|
|
331
|
+
commands.push(recovered[i]);
|
|
332
|
+
}
|
|
333
|
+
const lexerErrors = this.tok._errors;
|
|
334
|
+
if (lexerErrors !== null && lexerErrors.length > 0) {
|
|
335
|
+
const errors = this.errors ?? (this.errors = []);
|
|
336
|
+
for (let i = 0; i < lexerErrors.length; i++)
|
|
337
|
+
errors.push(lexerErrors[i]);
|
|
338
|
+
}
|
|
339
|
+
if (this.errors !== null && this.errors.length > 1)
|
|
340
|
+
this.errors.sort((a, b) => a.pos - b.pos);
|
|
341
|
+
return {
|
|
342
|
+
type: "Script",
|
|
343
|
+
pos: start,
|
|
344
|
+
end: this.end,
|
|
345
|
+
shebang,
|
|
346
|
+
commands,
|
|
347
|
+
errors: this.errors ?? undefined,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
error(message, pos) {
|
|
351
|
+
(this.errors ?? (this.errors = [])).push({ message, pos });
|
|
352
|
+
}
|
|
353
|
+
skipSemi() {
|
|
354
|
+
if (this.tok.peek(LexContext.Normal).token === Token.Semi)
|
|
355
|
+
this.tok.next(LexContext.Normal);
|
|
356
|
+
}
|
|
357
|
+
accept(token, ctx = LexContext.Normal) {
|
|
358
|
+
if (this.tok.peek(ctx).token === token)
|
|
359
|
+
return this.tok.next(ctx);
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
acceptEnd(token, ctx = LexContext.Normal) {
|
|
363
|
+
if (this.tok.peek(ctx).token === token)
|
|
364
|
+
return this.tok.next(ctx).end;
|
|
365
|
+
return -1;
|
|
366
|
+
}
|
|
367
|
+
skipNewlines(ctx = LexContext.Normal) {
|
|
368
|
+
while (this.tok.peek(ctx).token === Token.Newline)
|
|
369
|
+
this.tok.next(ctx);
|
|
370
|
+
}
|
|
371
|
+
makeStatement(command) {
|
|
372
|
+
return {
|
|
373
|
+
type: "Statement",
|
|
374
|
+
pos: command.pos,
|
|
375
|
+
end: command.end,
|
|
376
|
+
command,
|
|
377
|
+
background: undefined,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
// list := and_or ((';' | '&' | NEWLINE) and_or)* [';' | '&' | NEWLINE]
|
|
381
|
+
list() {
|
|
382
|
+
const commands = [];
|
|
383
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
384
|
+
let t = this.tok.peek(LexContext.CommandStart).token;
|
|
385
|
+
if (listTerminators[t] || !commandStarts[t])
|
|
386
|
+
return commands;
|
|
387
|
+
const first = this.andOr();
|
|
388
|
+
if (first)
|
|
389
|
+
commands.push(this.makeStatement(first));
|
|
390
|
+
for (;;) {
|
|
391
|
+
t = this.tok.peekFollow(compoundClosers).token;
|
|
392
|
+
if (t !== Token.Semi && t !== Token.Newline && t !== Token.Amp)
|
|
393
|
+
break;
|
|
394
|
+
const isBackground = t === Token.Amp;
|
|
395
|
+
const sepEnd = this.tok.next(LexContext.Normal).end;
|
|
396
|
+
if (isBackground) {
|
|
397
|
+
const stmt = commands[commands.length - 1];
|
|
398
|
+
stmt.background = true;
|
|
399
|
+
stmt.end = sepEnd;
|
|
400
|
+
}
|
|
401
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
402
|
+
t = this.tok.peek(LexContext.CommandStart).token;
|
|
403
|
+
if (listTerminators[t] || !commandStarts[t])
|
|
404
|
+
break;
|
|
405
|
+
const node = this.andOr();
|
|
406
|
+
if (node)
|
|
407
|
+
commands.push(this.makeStatement(node));
|
|
408
|
+
}
|
|
409
|
+
return commands;
|
|
410
|
+
}
|
|
411
|
+
// and_or := pipeline (('&&' | '||') newlines pipeline)*
|
|
412
|
+
andOr() {
|
|
413
|
+
const first = this.pipeline();
|
|
414
|
+
if (!first)
|
|
415
|
+
return null;
|
|
416
|
+
let t = this.tok.peek(LexContext.Normal).token;
|
|
417
|
+
if (t !== Token.And && t !== Token.Or)
|
|
418
|
+
return first;
|
|
419
|
+
const commands = [first];
|
|
420
|
+
const operators = [];
|
|
421
|
+
do {
|
|
422
|
+
const operatorToken = this.tok.next(LexContext.Normal);
|
|
423
|
+
const operator = operatorToken.token === Token.And ? "&&" : "||";
|
|
424
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
425
|
+
const next = this.pipeline();
|
|
426
|
+
if (!next) {
|
|
427
|
+
this.error(`expected command after '${operator}'`, operatorToken.end);
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
operators.push(operator);
|
|
431
|
+
commands.push(next);
|
|
432
|
+
t = this.tok.peek(LexContext.Normal).token;
|
|
433
|
+
} while (t === Token.And || t === Token.Or);
|
|
434
|
+
return {
|
|
435
|
+
type: "AndOr",
|
|
436
|
+
pos: first.pos,
|
|
437
|
+
end: commands[commands.length - 1].end,
|
|
438
|
+
commands,
|
|
439
|
+
operators,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
withRedirects(command) {
|
|
443
|
+
const redirects = this.collectTrailingRedirects();
|
|
444
|
+
if (redirects.length === 0)
|
|
445
|
+
return command;
|
|
446
|
+
return { type: "Redirected", pos: command.pos, end: redirects[redirects.length - 1].end, command, redirects };
|
|
447
|
+
}
|
|
448
|
+
pipeline() {
|
|
449
|
+
let prefixes;
|
|
450
|
+
let exceeded = false;
|
|
451
|
+
for (;;) {
|
|
452
|
+
const token = this.tok.peek(LexContext.CommandStart);
|
|
453
|
+
const isTime = token.token === Token.Word && token.keywordEligible && token.value === "time";
|
|
454
|
+
if (token.token !== Token.Bang && !isTime)
|
|
455
|
+
break;
|
|
456
|
+
const prefix = this.tok.next(LexContext.CommandStart);
|
|
457
|
+
const pos = prefix.pos;
|
|
458
|
+
const keywordEnd = prefix.end;
|
|
459
|
+
let posix;
|
|
460
|
+
let endOfOptions;
|
|
461
|
+
if (isTime) {
|
|
462
|
+
let flag = this.tok.peek(LexContext.CommandStart);
|
|
463
|
+
if (flag.token === Token.Word && flag.keywordEligible && flag.value === "-p") {
|
|
464
|
+
this.tok.next(LexContext.CommandStart);
|
|
465
|
+
posix = { pos: flag.pos, end: flag.end };
|
|
466
|
+
flag = this.tok.peek(LexContext.CommandStart);
|
|
467
|
+
}
|
|
468
|
+
if (flag.token === Token.Word && flag.keywordEligible && flag.value === "--") {
|
|
469
|
+
this.tok.next(LexContext.CommandStart);
|
|
470
|
+
endOfOptions = { pos: flag.pos, end: flag.end };
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
if (prefixes === undefined)
|
|
474
|
+
prefixes = [];
|
|
475
|
+
if (prefixes.length + this.syntaxDepth === MAX_SYNTAX_NESTING) {
|
|
476
|
+
if (!exceeded)
|
|
477
|
+
this.error("maximum pipeline prefix nesting depth exceeded", pos);
|
|
478
|
+
exceeded = true;
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
prefixes.push(isTime
|
|
482
|
+
? {
|
|
483
|
+
type: "Time",
|
|
484
|
+
pos,
|
|
485
|
+
end: endOfOptions?.end ?? posix?.end ?? keywordEnd,
|
|
486
|
+
keywordEnd,
|
|
487
|
+
posix,
|
|
488
|
+
endOfOptions,
|
|
489
|
+
command: undefined,
|
|
490
|
+
}
|
|
491
|
+
: { type: "Negation", pos, end: keywordEnd, keywordEnd, command: undefined });
|
|
492
|
+
}
|
|
493
|
+
if (!prefixes)
|
|
494
|
+
return this.pipelineCommands();
|
|
495
|
+
this.syntaxDepth += prefixes.length;
|
|
496
|
+
let command = this.pipelineCommands();
|
|
497
|
+
this.syntaxDepth -= prefixes.length;
|
|
498
|
+
for (let i = prefixes.length - 1; i >= 0; i--) {
|
|
499
|
+
const prefix = prefixes[i];
|
|
500
|
+
prefix.command = command ?? undefined;
|
|
501
|
+
if (command)
|
|
502
|
+
prefix.end = command.end;
|
|
503
|
+
command = prefix;
|
|
504
|
+
}
|
|
505
|
+
return command;
|
|
506
|
+
}
|
|
507
|
+
pipelineCommands() {
|
|
508
|
+
const first = this.command();
|
|
509
|
+
if (!first)
|
|
510
|
+
return null;
|
|
511
|
+
if (this.tok.peek(LexContext.Normal).token !== Token.Pipe)
|
|
512
|
+
return first;
|
|
513
|
+
const commands = [first];
|
|
514
|
+
const operators = [];
|
|
515
|
+
while (this.tok.peek(LexContext.Normal).token === Token.Pipe) {
|
|
516
|
+
const pipeToken = this.tok.next(LexContext.Normal);
|
|
517
|
+
const operator = pipeToken.value === "|&" ? "|&" : "|";
|
|
518
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
519
|
+
const cmd = this.command();
|
|
520
|
+
if (!cmd) {
|
|
521
|
+
this.error(`expected command after '${operator}'`, pipeToken.end);
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
operators.push(operator);
|
|
525
|
+
commands.push(cmd);
|
|
526
|
+
}
|
|
527
|
+
if (commands.length === 1) {
|
|
528
|
+
return commands[0];
|
|
529
|
+
}
|
|
530
|
+
const pipeline = {
|
|
531
|
+
type: "Pipeline",
|
|
532
|
+
pos: first.pos,
|
|
533
|
+
end: commands[commands.length - 1].end,
|
|
534
|
+
commands,
|
|
535
|
+
operators,
|
|
536
|
+
};
|
|
537
|
+
return pipeline;
|
|
538
|
+
}
|
|
539
|
+
// command := compound_command | function_def | simple_command
|
|
540
|
+
command() {
|
|
541
|
+
let compound;
|
|
542
|
+
switch (this.tok.peek(LexContext.CommandStart).token) {
|
|
543
|
+
case Token.LParen:
|
|
544
|
+
compound = this.subshell();
|
|
545
|
+
break;
|
|
546
|
+
case Token.LBrace:
|
|
547
|
+
compound = this.braceGroup();
|
|
548
|
+
break;
|
|
549
|
+
case Token.If:
|
|
550
|
+
compound = this.ifClause();
|
|
551
|
+
break;
|
|
552
|
+
case Token.For:
|
|
553
|
+
compound = this.forClause();
|
|
554
|
+
break;
|
|
555
|
+
case Token.While:
|
|
556
|
+
compound = this.whileClause();
|
|
557
|
+
break;
|
|
558
|
+
case Token.Until:
|
|
559
|
+
compound = this.untilClause();
|
|
560
|
+
break;
|
|
561
|
+
case Token.Case:
|
|
562
|
+
compound = this.caseClause();
|
|
563
|
+
break;
|
|
564
|
+
case Token.Function:
|
|
565
|
+
return this.functionDef();
|
|
566
|
+
case Token.Select:
|
|
567
|
+
compound = this.selectClause();
|
|
568
|
+
break;
|
|
569
|
+
case Token.DblLBracket:
|
|
570
|
+
compound = this.testCommand();
|
|
571
|
+
break;
|
|
572
|
+
case Token.ArithCmd:
|
|
573
|
+
compound = this.arithCommand();
|
|
574
|
+
break;
|
|
575
|
+
case Token.Coproc:
|
|
576
|
+
return this.coprocCommand();
|
|
577
|
+
case Token.Word:
|
|
578
|
+
case Token.Assignment:
|
|
579
|
+
case Token.Redirect:
|
|
580
|
+
return this.simpleCommandOrFunction();
|
|
581
|
+
default:
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
return this.withRedirects(compound);
|
|
585
|
+
}
|
|
586
|
+
collectTrailingRedirects() {
|
|
587
|
+
let redirects = EMPTY_REDIRECTS;
|
|
588
|
+
while (this.tok.peekFollow(compoundClosers).token === Token.Redirect) {
|
|
589
|
+
if (redirects === EMPTY_REDIRECTS)
|
|
590
|
+
redirects = [];
|
|
591
|
+
redirects.push(this.readRedirect(LexContext.Normal));
|
|
592
|
+
}
|
|
593
|
+
return redirects;
|
|
594
|
+
}
|
|
595
|
+
// arith_command := (( expr ))
|
|
596
|
+
arithCommand() {
|
|
597
|
+
const tok = this.tok.next(LexContext.CommandStart);
|
|
598
|
+
return new ArithmeticCommandImpl(tok.pos, tok.end, tok.value, this.source, this.depth);
|
|
599
|
+
}
|
|
600
|
+
// coproc := COPROC ([name] compound_command [redirections] | simple_command)
|
|
601
|
+
coprocCommand() {
|
|
602
|
+
const start = this.tok.next(LexContext.CommandStart);
|
|
603
|
+
const pos = start.pos;
|
|
604
|
+
const first = this.tok.peek(LexContext.CommandStart);
|
|
605
|
+
let name;
|
|
606
|
+
// Only a compound command can follow a coprocess name. Decide before parsing
|
|
607
|
+
// a simple command so its assignments and reserved words use the actual name.
|
|
608
|
+
if (first.token === Token.Word) {
|
|
609
|
+
const lookahead = new Lexer(this.source, first.end, this.end);
|
|
610
|
+
lookahead._nestingDepth = this.depth;
|
|
611
|
+
switch (lookahead.peek(LexContext.CommandStart).token) {
|
|
612
|
+
case Token.LParen:
|
|
613
|
+
// `name ( )` opens a function definition, not a subshell body after a name.
|
|
614
|
+
lookahead.next(LexContext.CommandStart);
|
|
615
|
+
if (lookahead.peek(LexContext.Normal).token !== Token.RParen)
|
|
616
|
+
name = this.readWord(LexContext.CommandStart);
|
|
617
|
+
break;
|
|
618
|
+
case Token.LBrace:
|
|
619
|
+
case Token.If:
|
|
620
|
+
case Token.For:
|
|
621
|
+
case Token.While:
|
|
622
|
+
case Token.Until:
|
|
623
|
+
case Token.Case:
|
|
624
|
+
case Token.Select:
|
|
625
|
+
case Token.DblLBracket:
|
|
626
|
+
case Token.ArithCmd:
|
|
627
|
+
name = this.readWord(LexContext.CommandStart);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
const cmd = this.command();
|
|
631
|
+
if (cmd && cmd.type !== "Function" && cmd.type !== "Coproc") {
|
|
632
|
+
return { type: "Coproc", pos, end: cmd.end, name, body: cmd };
|
|
633
|
+
}
|
|
634
|
+
this.error("expected command after 'coproc'", cmd?.pos ?? start.end);
|
|
635
|
+
const body = cmd
|
|
636
|
+
? this.makeCompoundList([this.makeStatement(cmd)])
|
|
637
|
+
: { type: "CompoundList", pos: start.end, end: start.end, commands: [] };
|
|
638
|
+
return { type: "Coproc", pos, end: body.end, name, body };
|
|
639
|
+
}
|
|
640
|
+
// subshell := '(' list ')'
|
|
641
|
+
subshell() {
|
|
642
|
+
return this.subshellBody(this.tok.next(LexContext.CommandStart).pos);
|
|
643
|
+
}
|
|
644
|
+
// Continues a subshell whose '(' the caller already consumed.
|
|
645
|
+
subshellBody(pos) {
|
|
646
|
+
if (this.syntaxDepth === MAX_SYNTAX_NESTING) {
|
|
647
|
+
this.error("maximum subshell nesting depth exceeded", pos);
|
|
648
|
+
const closeEnd = this.tok.skipSubshellBody();
|
|
649
|
+
if (closeEnd < 0)
|
|
650
|
+
this.error("expected ')' to close subshell", this.tok.getPos());
|
|
651
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
652
|
+
return { type: "Subshell", pos, end, body: this.makeCompoundList([]) };
|
|
653
|
+
}
|
|
654
|
+
this.syntaxDepth++;
|
|
655
|
+
const commands = this.list();
|
|
656
|
+
this.syntaxDepth--;
|
|
657
|
+
if (commands.length === 0)
|
|
658
|
+
this.error("expected command in subshell", pos);
|
|
659
|
+
const closeEnd = this.acceptEnd(Token.RParen, LexContext.Normal);
|
|
660
|
+
if (closeEnd < 0)
|
|
661
|
+
this.error("expected ')' to close subshell", this.tok.getPos());
|
|
662
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
663
|
+
return { type: "Subshell", pos, end, body: this.makeCompoundList(commands) };
|
|
664
|
+
}
|
|
665
|
+
// brace_group := '{' list '}'
|
|
666
|
+
braceGroup() {
|
|
667
|
+
const pos = this.tok.next(LexContext.CommandStart).pos;
|
|
668
|
+
if (this.syntaxDepth === MAX_SYNTAX_NESTING) {
|
|
669
|
+
this.error("maximum brace group nesting depth exceeded", pos);
|
|
670
|
+
const closeEnd = this.tok.skipCompoundBody(Token.RBrace);
|
|
671
|
+
if (closeEnd < 0)
|
|
672
|
+
this.error("expected '}' to close brace group", this.tok.getPos());
|
|
673
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
674
|
+
return { type: "BraceGroup", pos, end, body: this.makeCompoundList([]) };
|
|
675
|
+
}
|
|
676
|
+
this.syntaxDepth++;
|
|
677
|
+
const commands = this.list();
|
|
678
|
+
this.syntaxDepth--;
|
|
679
|
+
if (commands.length === 0)
|
|
680
|
+
this.error("expected command in brace group", pos);
|
|
681
|
+
const closeEnd = this.acceptEnd(Token.RBrace, LexContext.Normal);
|
|
682
|
+
if (closeEnd < 0)
|
|
683
|
+
this.error("expected '}' to close brace group", this.tok.getPos());
|
|
684
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
685
|
+
return { type: "BraceGroup", pos, end, body: this.makeCompoundList(commands) };
|
|
686
|
+
}
|
|
687
|
+
// if_clause := IF list THEN list (ELIF list THEN list)* [ELSE list] FI
|
|
688
|
+
ifClause() {
|
|
689
|
+
const pos = this.tok.next(LexContext.CommandStart).pos;
|
|
690
|
+
if (this.syntaxDepth === MAX_SYNTAX_NESTING) {
|
|
691
|
+
this.error("maximum if nesting depth exceeded", pos);
|
|
692
|
+
const closeEnd = this.tok.skipCompoundBody(Token.Fi);
|
|
693
|
+
if (closeEnd < 0)
|
|
694
|
+
this.error("expected 'fi' to close 'if'", this.tok.getPos());
|
|
695
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
696
|
+
return {
|
|
697
|
+
type: "If",
|
|
698
|
+
pos,
|
|
699
|
+
end,
|
|
700
|
+
clause: this.makeCompoundList([]),
|
|
701
|
+
then: this.makeCompoundList([]),
|
|
702
|
+
else: undefined,
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
this.syntaxDepth++;
|
|
706
|
+
let firstBranch;
|
|
707
|
+
let lastBranch;
|
|
708
|
+
let branchPos = pos;
|
|
709
|
+
let clause;
|
|
710
|
+
let then_;
|
|
711
|
+
for (;;) {
|
|
712
|
+
clause = this.makeCompoundList(this.list());
|
|
713
|
+
this.skipSemi();
|
|
714
|
+
const thenToken = this.accept(Token.Then, LexContext.CommandStart);
|
|
715
|
+
if (!thenToken)
|
|
716
|
+
this.error("expected 'then'", this.tok.getPos());
|
|
717
|
+
const thenCommands = this.list();
|
|
718
|
+
if (thenToken && thenCommands.length === 0)
|
|
719
|
+
this.error("expected command after 'then'", this.tok.peek(LexContext.CommandStart).pos);
|
|
720
|
+
then_ = this.makeCompoundList(thenCommands);
|
|
721
|
+
this.skipSemi();
|
|
722
|
+
const elif = this.accept(Token.Elif, LexContext.CommandStart);
|
|
723
|
+
if (!elif)
|
|
724
|
+
break;
|
|
725
|
+
const branch = {
|
|
726
|
+
type: "If",
|
|
727
|
+
pos: branchPos,
|
|
728
|
+
end: branchPos,
|
|
729
|
+
clause,
|
|
730
|
+
then: then_,
|
|
731
|
+
else: undefined,
|
|
732
|
+
};
|
|
733
|
+
if (lastBranch)
|
|
734
|
+
lastBranch.else = branch;
|
|
735
|
+
else
|
|
736
|
+
firstBranch = branch;
|
|
737
|
+
lastBranch = branch;
|
|
738
|
+
branchPos = elif.pos;
|
|
739
|
+
}
|
|
740
|
+
let else_;
|
|
741
|
+
let end;
|
|
742
|
+
if (this.accept(Token.Else, LexContext.CommandStart)) {
|
|
743
|
+
else_ = this.makeCompoundList(this.list());
|
|
744
|
+
this.skipSemi();
|
|
745
|
+
const closeEnd = this.acceptEnd(Token.Fi, LexContext.CommandStart);
|
|
746
|
+
if (closeEnd < 0)
|
|
747
|
+
this.error("expected 'fi' to close 'if'", this.tok.getPos());
|
|
748
|
+
end = closeEnd >= 0 ? closeEnd : branchPos;
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
const closeEnd = this.acceptEnd(Token.Fi, LexContext.CommandStart);
|
|
752
|
+
if (closeEnd < 0)
|
|
753
|
+
this.error("expected 'fi' to close 'if'", this.tok.getPos());
|
|
754
|
+
end = closeEnd >= 0 ? closeEnd : branchPos;
|
|
755
|
+
}
|
|
756
|
+
this.syntaxDepth--;
|
|
757
|
+
const finalBranch = { type: "If", pos: branchPos, end, clause, then: then_, else: else_ };
|
|
758
|
+
if (!firstBranch)
|
|
759
|
+
return finalBranch;
|
|
760
|
+
lastBranch.else = finalBranch;
|
|
761
|
+
let branch = firstBranch;
|
|
762
|
+
while (branch?.type === "If") {
|
|
763
|
+
branch.end = end;
|
|
764
|
+
branch = branch.else;
|
|
765
|
+
}
|
|
766
|
+
return firstBranch;
|
|
767
|
+
}
|
|
768
|
+
// for_clause := FOR word [IN word* (';'|NL)] DO list DONE
|
|
769
|
+
// | FOR '((' expr '))' [';'|NL] DO list DONE
|
|
770
|
+
forClause() {
|
|
771
|
+
const pos = this.tok.next(LexContext.CommandStart).pos;
|
|
772
|
+
if (this.tok.peek(LexContext.Normal).token === Token.LParen) {
|
|
773
|
+
return this.cStyleFor(pos);
|
|
774
|
+
}
|
|
775
|
+
const name = this.readWord(LexContext.Normal);
|
|
776
|
+
let wordlist;
|
|
777
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
778
|
+
if (this.tok.peek(LexContext.CommandStart).token === Token.In) {
|
|
779
|
+
this.tok.next(LexContext.CommandStart);
|
|
780
|
+
wordlist = [];
|
|
781
|
+
while (this.tok.peek(LexContext.Normal).token === Token.Word) {
|
|
782
|
+
wordlist.push(this.readWord(LexContext.Normal));
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
this.skipSemi();
|
|
786
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
787
|
+
if (this.tok.peek(LexContext.CommandStart).token === Token.LBrace) {
|
|
788
|
+
const bg = this.braceGroup();
|
|
789
|
+
return { type: "For", pos, end: bg.end, name, wordlist, body: bg.body };
|
|
790
|
+
}
|
|
791
|
+
if (!this.accept(Token.Do, LexContext.CommandStart))
|
|
792
|
+
this.error("expected 'do'", this.tok.getPos());
|
|
793
|
+
if (this.syntaxDepth === MAX_SYNTAX_NESTING) {
|
|
794
|
+
this.error("maximum for nesting depth exceeded", pos);
|
|
795
|
+
const closeEnd = this.tok.skipCompoundBody(Token.Done);
|
|
796
|
+
if (closeEnd < 0)
|
|
797
|
+
this.error("expected 'done' to close 'for'", this.tok.getPos());
|
|
798
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
799
|
+
return { type: "For", pos, end, name, wordlist, body: this.makeCompoundList([]) };
|
|
800
|
+
}
|
|
801
|
+
this.syntaxDepth++;
|
|
802
|
+
const body = this.list();
|
|
803
|
+
this.syntaxDepth--;
|
|
804
|
+
this.skipSemi();
|
|
805
|
+
const closeEnd = this.acceptEnd(Token.Done, LexContext.CommandStart);
|
|
806
|
+
if (closeEnd < 0)
|
|
807
|
+
this.error("expected 'done' to close 'for'", this.tok.getPos());
|
|
808
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
809
|
+
return { type: "For", pos, end, name, wordlist, body: this.makeCompoundList(body) };
|
|
810
|
+
}
|
|
811
|
+
// C-style for: (( expr; expr; expr )) [;|NL] do list done | { list }
|
|
812
|
+
cStyleFor(pos) {
|
|
813
|
+
const [initStr, testStr, updateStr, initPos, testPos, updatePos] = this.tok.readCStyleForExprs();
|
|
814
|
+
if (this.tok.peek(LexContext.CommandStart).token === Token.Semi)
|
|
815
|
+
this.tok.next(LexContext.CommandStart);
|
|
816
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
817
|
+
if (this.tok.peek(LexContext.CommandStart).token === Token.LBrace) {
|
|
818
|
+
const bg = this.braceGroup();
|
|
819
|
+
return new ArithmeticForImpl(pos, bg.end, bg.body, initStr, testStr, updateStr, initPos, testPos, updatePos, this.source, this.depth);
|
|
820
|
+
}
|
|
821
|
+
if (!this.accept(Token.Do, LexContext.CommandStart))
|
|
822
|
+
this.error("expected 'do'", this.tok.getPos());
|
|
823
|
+
if (this.syntaxDepth === MAX_SYNTAX_NESTING) {
|
|
824
|
+
this.error("maximum for nesting depth exceeded", pos);
|
|
825
|
+
const closeEnd = this.tok.skipCompoundBody(Token.Done);
|
|
826
|
+
if (closeEnd < 0)
|
|
827
|
+
this.error("expected 'done' to close 'for'", this.tok.getPos());
|
|
828
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
829
|
+
return new ArithmeticForImpl(pos, end, this.makeCompoundList([]), initStr, testStr, updateStr, initPos, testPos, updatePos, this.source, this.depth);
|
|
830
|
+
}
|
|
831
|
+
this.syntaxDepth++;
|
|
832
|
+
const body = this.list();
|
|
833
|
+
this.syntaxDepth--;
|
|
834
|
+
const closeEnd = this.acceptEnd(Token.Done, LexContext.CommandStart);
|
|
835
|
+
if (closeEnd < 0)
|
|
836
|
+
this.error("expected 'done' to close 'for'", this.tok.getPos());
|
|
837
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
838
|
+
return new ArithmeticForImpl(pos, end, this.makeCompoundList(body), initStr, testStr, updateStr, initPos, testPos, updatePos, this.source, this.depth);
|
|
839
|
+
}
|
|
840
|
+
whileClause() {
|
|
841
|
+
return this.whileOrUntil("while");
|
|
842
|
+
}
|
|
843
|
+
untilClause() {
|
|
844
|
+
return this.whileOrUntil("until");
|
|
845
|
+
}
|
|
846
|
+
whileOrUntil(kind) {
|
|
847
|
+
const pos = this.tok.next(LexContext.CommandStart).pos;
|
|
848
|
+
if (this.syntaxDepth === MAX_SYNTAX_NESTING) {
|
|
849
|
+
this.error(`maximum ${kind} nesting depth exceeded`, pos);
|
|
850
|
+
const closeEnd = this.tok.skipCompoundBody(Token.Done);
|
|
851
|
+
if (closeEnd < 0)
|
|
852
|
+
this.error(`expected 'done' to close '${kind}'`, this.tok.getPos());
|
|
853
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
854
|
+
return {
|
|
855
|
+
type: "While",
|
|
856
|
+
pos,
|
|
857
|
+
end,
|
|
858
|
+
kind,
|
|
859
|
+
clause: this.makeCompoundList([]),
|
|
860
|
+
body: this.makeCompoundList([]),
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
this.syntaxDepth++;
|
|
864
|
+
const clause = this.makeCompoundList(this.list());
|
|
865
|
+
this.skipSemi();
|
|
866
|
+
if (!this.accept(Token.Do, LexContext.CommandStart))
|
|
867
|
+
this.error("expected 'do'", this.tok.getPos());
|
|
868
|
+
const body = this.list();
|
|
869
|
+
this.skipSemi();
|
|
870
|
+
const closeEnd = this.acceptEnd(Token.Done, LexContext.CommandStart);
|
|
871
|
+
if (closeEnd < 0)
|
|
872
|
+
this.error(`expected 'done' to close '${kind}'`, this.tok.getPos());
|
|
873
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
874
|
+
this.syntaxDepth--;
|
|
875
|
+
return { type: "While", pos, end, kind, clause, body: this.makeCompoundList(body) };
|
|
876
|
+
}
|
|
877
|
+
// case_clause := CASE word IN (pattern) list (;; | ;& | ;;&) ... ESAC
|
|
878
|
+
caseClause() {
|
|
879
|
+
const pos = this.tok.next(LexContext.CommandStart).pos;
|
|
880
|
+
const word = this.readWord(LexContext.Normal);
|
|
881
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
882
|
+
if (!this.accept(Token.In, LexContext.CommandStart))
|
|
883
|
+
this.error("expected 'in' after 'case' word", this.tok.getPos());
|
|
884
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
885
|
+
if (this.syntaxDepth === MAX_SYNTAX_NESTING) {
|
|
886
|
+
this.error("maximum case nesting depth exceeded", pos);
|
|
887
|
+
const closeEnd = this.tok.skipCompoundBody(Token.Esac);
|
|
888
|
+
if (closeEnd < 0)
|
|
889
|
+
this.error("expected 'esac' to close 'case'", this.tok.getPos());
|
|
890
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
891
|
+
return { type: "Case", pos, end, word, items: [] };
|
|
892
|
+
}
|
|
893
|
+
this.syntaxDepth++;
|
|
894
|
+
const items = [];
|
|
895
|
+
let t = this.tok.peek(LexContext.CommandStart).token;
|
|
896
|
+
while (t !== Token.Esac && t !== Token.EOF) {
|
|
897
|
+
const itemPos = this.tok.peek(LexContext.Normal).pos;
|
|
898
|
+
this.accept(Token.LParen, LexContext.Normal);
|
|
899
|
+
const pattern = [];
|
|
900
|
+
t = this.tok.peek(LexContext.Normal).token;
|
|
901
|
+
while (t !== Token.RParen && t !== Token.EOF) {
|
|
902
|
+
if (t !== Token.Pipe)
|
|
903
|
+
pattern.push(this.toWord(this.tok.next(LexContext.Normal)));
|
|
904
|
+
else
|
|
905
|
+
this.tok.next(LexContext.Normal);
|
|
906
|
+
t = this.tok.peek(LexContext.Normal).token;
|
|
907
|
+
}
|
|
908
|
+
const rparenEnd = this.acceptEnd(Token.RParen, LexContext.Normal);
|
|
909
|
+
const cmds = this.list();
|
|
910
|
+
// An empty body belongs where commands would start, not wherever the lexer stopped.
|
|
911
|
+
const bodyPos = rparenEnd >= 0 ? rparenEnd : pattern.length > 0 ? pattern[pattern.length - 1].end : itemPos;
|
|
912
|
+
const itemEnd = cmds.length > 0 ? cmds[cmds.length - 1].end : bodyPos;
|
|
913
|
+
const item = {
|
|
914
|
+
type: "CaseItem",
|
|
915
|
+
pos: itemPos,
|
|
916
|
+
end: itemEnd,
|
|
917
|
+
pattern,
|
|
918
|
+
body: cmds.length > 0
|
|
919
|
+
? this.makeCompoundList(cmds)
|
|
920
|
+
: { type: "CompoundList", pos: bodyPos, end: bodyPos, commands: [] },
|
|
921
|
+
terminator: undefined,
|
|
922
|
+
};
|
|
923
|
+
t = this.tok.peek(LexContext.CommandStart).token;
|
|
924
|
+
if (t === Token.DoubleSemi || t === Token.SemiAmp || t === Token.DoubleSemiAmp) {
|
|
925
|
+
const termTok = this.tok.next(LexContext.CommandStart);
|
|
926
|
+
item.terminator = CASE_TERMINATORS[termTok.token];
|
|
927
|
+
item.end = termTok.end;
|
|
928
|
+
}
|
|
929
|
+
items.push(item);
|
|
930
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
931
|
+
t = this.tok.peek(LexContext.CommandStart).token;
|
|
932
|
+
}
|
|
933
|
+
const closeEnd = this.acceptEnd(Token.Esac, LexContext.CommandStart);
|
|
934
|
+
if (closeEnd < 0)
|
|
935
|
+
this.error("expected 'esac' to close 'case'", this.tok.getPos());
|
|
936
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
937
|
+
this.syntaxDepth--;
|
|
938
|
+
return { type: "Case", pos, end, word, items };
|
|
939
|
+
}
|
|
940
|
+
// select_clause := SELECT word [IN word* (';'|NL)] DO list DONE
|
|
941
|
+
selectClause() {
|
|
942
|
+
const pos = this.tok.next(LexContext.CommandStart).pos;
|
|
943
|
+
const name = this.readWord(LexContext.Normal);
|
|
944
|
+
let wordlist;
|
|
945
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
946
|
+
if (this.tok.peek(LexContext.CommandStart).token === Token.In) {
|
|
947
|
+
this.tok.next(LexContext.CommandStart);
|
|
948
|
+
wordlist = [];
|
|
949
|
+
while (this.tok.peek(LexContext.Normal).token === Token.Word) {
|
|
950
|
+
wordlist.push(this.readWord(LexContext.Normal));
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
this.skipSemi();
|
|
954
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
955
|
+
if (this.tok.peek(LexContext.CommandStart).token === Token.LBrace) {
|
|
956
|
+
const bg = this.braceGroup();
|
|
957
|
+
return { type: "Select", pos, end: bg.end, name, wordlist, body: bg.body };
|
|
958
|
+
}
|
|
959
|
+
if (!this.accept(Token.Do, LexContext.CommandStart))
|
|
960
|
+
this.error("expected 'do'", this.tok.getPos());
|
|
961
|
+
if (this.syntaxDepth === MAX_SYNTAX_NESTING) {
|
|
962
|
+
this.error("maximum select nesting depth exceeded", pos);
|
|
963
|
+
const closeEnd = this.tok.skipCompoundBody(Token.Done);
|
|
964
|
+
if (closeEnd < 0)
|
|
965
|
+
this.error("expected 'done' to close 'select'", this.tok.getPos());
|
|
966
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
967
|
+
return { type: "Select", pos, end, name, wordlist, body: this.makeCompoundList([]) };
|
|
968
|
+
}
|
|
969
|
+
this.syntaxDepth++;
|
|
970
|
+
const body = this.list();
|
|
971
|
+
this.syntaxDepth--;
|
|
972
|
+
this.skipSemi();
|
|
973
|
+
const closeEnd = this.acceptEnd(Token.Done, LexContext.CommandStart);
|
|
974
|
+
if (closeEnd < 0)
|
|
975
|
+
this.error("expected 'done' to close 'select'", this.tok.getPos());
|
|
976
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
977
|
+
return { type: "Select", pos, end, name, wordlist, body: this.makeCompoundList(body) };
|
|
978
|
+
}
|
|
979
|
+
// test_command := [[ test_expr ]]
|
|
980
|
+
testCommand() {
|
|
981
|
+
const pos = this.tok.next(LexContext.CommandStart).pos; // consume [[
|
|
982
|
+
const expr = this.parseTestOr();
|
|
983
|
+
const closeEnd = this.acceptEnd(Token.DblRBracket, LexContext.TestMode);
|
|
984
|
+
if (closeEnd < 0)
|
|
985
|
+
this.error("expected ']]' to close '[['", this.tok.getPos());
|
|
986
|
+
const end = closeEnd >= 0 ? closeEnd : pos;
|
|
987
|
+
return { type: "TestCommand", pos, end, expression: expr };
|
|
988
|
+
}
|
|
989
|
+
// test_or := test_and ('||' test_and)*
|
|
990
|
+
parseTestOr() {
|
|
991
|
+
let left = this.parseTestAnd();
|
|
992
|
+
while (this.tok.peek(LexContext.TestMode).token === Token.Or) {
|
|
993
|
+
this.tok.next(LexContext.TestMode);
|
|
994
|
+
const right = this.parseTestAnd();
|
|
995
|
+
left = {
|
|
996
|
+
type: "TestLogical",
|
|
997
|
+
pos: left.pos,
|
|
998
|
+
end: right.end,
|
|
999
|
+
operator: "||",
|
|
1000
|
+
left,
|
|
1001
|
+
right,
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
return left;
|
|
1005
|
+
}
|
|
1006
|
+
// test_and := test_not ('&&' test_not)*
|
|
1007
|
+
parseTestAnd() {
|
|
1008
|
+
let left = this.parseTestNot();
|
|
1009
|
+
while (this.tok.peek(LexContext.TestMode).token === Token.And) {
|
|
1010
|
+
this.tok.next(LexContext.TestMode);
|
|
1011
|
+
const right = this.parseTestNot();
|
|
1012
|
+
left = {
|
|
1013
|
+
type: "TestLogical",
|
|
1014
|
+
pos: left.pos,
|
|
1015
|
+
end: right.end,
|
|
1016
|
+
operator: "&&",
|
|
1017
|
+
left,
|
|
1018
|
+
right,
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
return left;
|
|
1022
|
+
}
|
|
1023
|
+
// test_not := '!' test_not | test_primary
|
|
1024
|
+
parseTestNot() {
|
|
1025
|
+
let t = this.tok.peek(LexContext.TestMode);
|
|
1026
|
+
if (!isTestNegation(t))
|
|
1027
|
+
return this.parseTestPrimary();
|
|
1028
|
+
const firstPos = this.tok.next(LexContext.TestMode).pos;
|
|
1029
|
+
t = this.tok.peek(LexContext.TestMode);
|
|
1030
|
+
if (!isTestNegation(t)) {
|
|
1031
|
+
const operand = this.parseTestPrimary();
|
|
1032
|
+
return { type: "TestNot", pos: firstPos, end: operand.end, operand };
|
|
1033
|
+
}
|
|
1034
|
+
const positions = [firstPos];
|
|
1035
|
+
while (isTestNegation(t)) {
|
|
1036
|
+
positions.push(this.tok.next(LexContext.TestMode).pos);
|
|
1037
|
+
t = this.tok.peek(LexContext.TestMode);
|
|
1038
|
+
}
|
|
1039
|
+
let expression = this.parseTestPrimary();
|
|
1040
|
+
for (let i = positions.length - 1; i >= 0; i--) {
|
|
1041
|
+
expression = {
|
|
1042
|
+
type: "TestNot",
|
|
1043
|
+
pos: positions[i],
|
|
1044
|
+
end: expression.end,
|
|
1045
|
+
operand: expression,
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
return expression;
|
|
1049
|
+
}
|
|
1050
|
+
// test_primary := '(' test_or ')' | unary_op word | word binary_op word | word
|
|
1051
|
+
parseTestPrimary() {
|
|
1052
|
+
// Grouped: ( expr )
|
|
1053
|
+
if (this.tok.peek(LexContext.TestMode).token === Token.LParen) {
|
|
1054
|
+
const openPos = this.tok.next(LexContext.TestMode).pos;
|
|
1055
|
+
if (this.syntaxDepth === MAX_SYNTAX_NESTING) {
|
|
1056
|
+
this.error("maximum test group nesting depth exceeded", openPos);
|
|
1057
|
+
const closeEnd = this.tok.skipTestGroup();
|
|
1058
|
+
if (closeEnd < 0)
|
|
1059
|
+
this.error("expected ')' to close test group", this.tok.getPos());
|
|
1060
|
+
const end = closeEnd >= 0 ? closeEnd : openPos;
|
|
1061
|
+
const operand = new WordImpl("", openPos, openPos, this.source, undefined, this.depth);
|
|
1062
|
+
const expression = {
|
|
1063
|
+
type: "TestUnary",
|
|
1064
|
+
pos: openPos,
|
|
1065
|
+
end: openPos,
|
|
1066
|
+
operator: "-n",
|
|
1067
|
+
operand,
|
|
1068
|
+
};
|
|
1069
|
+
return { type: "TestGroup", pos: openPos, end, expression };
|
|
1070
|
+
}
|
|
1071
|
+
this.syntaxDepth++;
|
|
1072
|
+
const expr = this.parseTestOr();
|
|
1073
|
+
this.syntaxDepth--;
|
|
1074
|
+
const closeEnd = this.acceptEnd(Token.RParen, LexContext.TestMode);
|
|
1075
|
+
if (closeEnd < 0)
|
|
1076
|
+
this.error("expected ')' to close test group", this.tok.getPos());
|
|
1077
|
+
const end = closeEnd >= 0 ? closeEnd : openPos;
|
|
1078
|
+
return { type: "TestGroup", pos: openPos, end, expression: expr };
|
|
1079
|
+
}
|
|
1080
|
+
const first = this.tok.next(LexContext.TestMode);
|
|
1081
|
+
const val = first.value;
|
|
1082
|
+
const firstPos = first.pos;
|
|
1083
|
+
const firstEnd = first.end;
|
|
1084
|
+
// Unary test: -op word, recognized only as written. Bash rejects the operator without an
|
|
1085
|
+
// operand, so keep the operator and report the missing word instead of demoting it to a string.
|
|
1086
|
+
if (first.keywordEligible && UNARY_TEST_OPS[val] === 1) {
|
|
1087
|
+
if (this.tok.peek(LexContext.TestMode).token === Token.Word) {
|
|
1088
|
+
const operand = this.readWord(LexContext.TestMode);
|
|
1089
|
+
return {
|
|
1090
|
+
type: "TestUnary",
|
|
1091
|
+
pos: firstPos,
|
|
1092
|
+
end: operand.end,
|
|
1093
|
+
operator: val,
|
|
1094
|
+
operand,
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
this.error("expected operand after unary test operator", firstEnd);
|
|
1098
|
+
const operand = new WordImpl("", firstEnd, firstEnd, this.source, undefined, this.depth);
|
|
1099
|
+
return { type: "TestUnary", pos: firstPos, end: firstEnd, operator: val, operand };
|
|
1100
|
+
}
|
|
1101
|
+
// Check for binary op
|
|
1102
|
+
const nt = this.tok.peek(LexContext.TestMode);
|
|
1103
|
+
if (nt.token === Token.Word && nt.keywordEligible && BINARY_TEST_OPS[nt.value] === 1) {
|
|
1104
|
+
const op = this.tok.next(LexContext.TestMode).value;
|
|
1105
|
+
let right;
|
|
1106
|
+
if (op === "=~") {
|
|
1107
|
+
const token = this.tok.readTestRegexWord();
|
|
1108
|
+
right = new WordImpl(this.source.slice(token.pos, token.end), token.pos, token.end, this.source, computeEmbeddedWordParts, this.depth);
|
|
1109
|
+
}
|
|
1110
|
+
else {
|
|
1111
|
+
right = this.readWord(LexContext.TestMode);
|
|
1112
|
+
}
|
|
1113
|
+
const left = this.toWordFromPosEnd(first, firstPos, firstEnd);
|
|
1114
|
+
return {
|
|
1115
|
+
type: "TestBinary",
|
|
1116
|
+
pos: firstPos,
|
|
1117
|
+
end: right.end,
|
|
1118
|
+
operator: op,
|
|
1119
|
+
left,
|
|
1120
|
+
right,
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
// Standalone word (implicit -n test)
|
|
1124
|
+
const w = this.toWordFromPosEnd(first, firstPos, firstEnd);
|
|
1125
|
+
return { type: "TestUnary", pos: firstPos, end: w.end, operator: "-n", operand: w };
|
|
1126
|
+
}
|
|
1127
|
+
// function_def with 'function' keyword
|
|
1128
|
+
functionDef() {
|
|
1129
|
+
const pos = this.tok.next(LexContext.CommandStart).pos;
|
|
1130
|
+
const name = this.readWord(LexContext.Normal);
|
|
1131
|
+
let body;
|
|
1132
|
+
if (this.tok.peek(LexContext.CommandStart).token === Token.LParen) {
|
|
1133
|
+
const openPos = this.tok.next(LexContext.CommandStart).pos;
|
|
1134
|
+
// `(` is the optional empty parameter list only when `)` follows immediately;
|
|
1135
|
+
// anything else opens a subshell body, as in `f() ( ... )`.
|
|
1136
|
+
if (this.tok.peek(LexContext.CommandStart).token === Token.RParen) {
|
|
1137
|
+
this.tok.next(LexContext.CommandStart);
|
|
1138
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
1139
|
+
body = this.commandAsBody();
|
|
1140
|
+
}
|
|
1141
|
+
else {
|
|
1142
|
+
body = this.withRedirects(this.subshellBody(openPos));
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
else {
|
|
1146
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
1147
|
+
body = this.commandAsBody();
|
|
1148
|
+
}
|
|
1149
|
+
return { type: "Function", pos, end: body.end, name, body };
|
|
1150
|
+
}
|
|
1151
|
+
// simple_command or function_def (word '(' ')' body)
|
|
1152
|
+
simpleCommandOrFunction() {
|
|
1153
|
+
const prefix = [];
|
|
1154
|
+
const cmdPos = this.tok.peek(LexContext.CommandStart).pos;
|
|
1155
|
+
let lastEnd = cmdPos;
|
|
1156
|
+
// Assignments and redirects interleave freely; after the first element CommandPrefix
|
|
1157
|
+
// keeps the following command name from being read as a reserved word.
|
|
1158
|
+
let ctx = LexContext.CommandStart;
|
|
1159
|
+
for (;;) {
|
|
1160
|
+
const t = this.tok.peek(ctx).token;
|
|
1161
|
+
if (t === Token.Assignment) {
|
|
1162
|
+
const assignment = this.tok.next(ctx);
|
|
1163
|
+
lastEnd = assignment.end;
|
|
1164
|
+
prefix.push(this.parseAssignment(assignment));
|
|
1165
|
+
}
|
|
1166
|
+
else if (t === Token.Redirect) {
|
|
1167
|
+
const redirect = this.readRedirect(ctx);
|
|
1168
|
+
prefix.push(redirect);
|
|
1169
|
+
lastEnd = redirect.end;
|
|
1170
|
+
}
|
|
1171
|
+
else {
|
|
1172
|
+
break;
|
|
1173
|
+
}
|
|
1174
|
+
ctx = LexContext.CommandPrefix;
|
|
1175
|
+
}
|
|
1176
|
+
if (this.tok.peek(LexContext.Normal).token !== Token.Word) {
|
|
1177
|
+
return new CommandImpl(cmdPos, lastEnd, undefined, prefix, []);
|
|
1178
|
+
}
|
|
1179
|
+
const nameToken = this.tok.next(LexContext.Normal);
|
|
1180
|
+
const declaration = nameToken.keywordEligible && isDeclarationCommand(nameToken.value);
|
|
1181
|
+
const name = this.toWord(nameToken);
|
|
1182
|
+
ctx = declaration ? LexContext.Declaration : LexContext.Normal;
|
|
1183
|
+
lastEnd = name.end;
|
|
1184
|
+
// Check for function definition: word '(' ')' body
|
|
1185
|
+
if (this.tok.peek(ctx).token === Token.LParen) {
|
|
1186
|
+
this.tok.next(LexContext.Normal);
|
|
1187
|
+
if (this.tok.peek(LexContext.Normal).token === Token.RParen) {
|
|
1188
|
+
this.tok.next(LexContext.Normal);
|
|
1189
|
+
this.skipNewlines(LexContext.CommandStart);
|
|
1190
|
+
const body = this.commandAsBody();
|
|
1191
|
+
return {
|
|
1192
|
+
type: "Function",
|
|
1193
|
+
pos: name.pos,
|
|
1194
|
+
end: body.end,
|
|
1195
|
+
name,
|
|
1196
|
+
body,
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
const suffix = [];
|
|
1201
|
+
// Collect suffix words and redirects
|
|
1202
|
+
for (;;) {
|
|
1203
|
+
const st = this.tok.peek(ctx).token;
|
|
1204
|
+
if (st === Token.Word || st === Token.Assignment) {
|
|
1205
|
+
const token = this.tok.next(ctx);
|
|
1206
|
+
const w = st === Token.Assignment ? this.parseAssignment(token) : this.toWord(token);
|
|
1207
|
+
suffix.push(w);
|
|
1208
|
+
lastEnd = w.end;
|
|
1209
|
+
}
|
|
1210
|
+
else if (st === Token.Redirect) {
|
|
1211
|
+
const redirect = this.readRedirect(ctx);
|
|
1212
|
+
suffix.push(redirect);
|
|
1213
|
+
lastEnd = redirect.end;
|
|
1214
|
+
}
|
|
1215
|
+
else {
|
|
1216
|
+
break;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
return new CommandImpl(cmdPos, lastEnd, name, prefix, suffix);
|
|
1220
|
+
}
|
|
1221
|
+
readRedirect(ctx) {
|
|
1222
|
+
const t = this.tok.next(ctx);
|
|
1223
|
+
const tPos = t.pos;
|
|
1224
|
+
const tEnd = t.end;
|
|
1225
|
+
const descriptor = t.fileDescriptor !== undefined
|
|
1226
|
+
? { type: "FileDescriptor", pos: tPos, end: t.descriptorEnd, value: t.fileDescriptor }
|
|
1227
|
+
: t.variableName !== undefined
|
|
1228
|
+
? { type: "FileDescriptorVariable", pos: tPos, end: t.descriptorEnd, name: t.variableName }
|
|
1229
|
+
: undefined;
|
|
1230
|
+
const hasTarget = t.targetEnd > t.targetPos;
|
|
1231
|
+
if (!hasTarget)
|
|
1232
|
+
this.error("expected redirect target", t.targetPos);
|
|
1233
|
+
if (t.value === "<<" || t.value === "<<-") {
|
|
1234
|
+
const r = {
|
|
1235
|
+
type: "HereDoc",
|
|
1236
|
+
pos: tPos,
|
|
1237
|
+
end: tEnd,
|
|
1238
|
+
operator: t.value,
|
|
1239
|
+
descriptor,
|
|
1240
|
+
delimiter: hasTarget
|
|
1241
|
+
? {
|
|
1242
|
+
type: "HereDocDelimiter",
|
|
1243
|
+
pos: t.targetPos,
|
|
1244
|
+
end: t.targetEnd,
|
|
1245
|
+
text: this.source.slice(t.targetPos, t.targetEnd),
|
|
1246
|
+
value: t.content ?? "",
|
|
1247
|
+
quoted: t.delimiterQuoted,
|
|
1248
|
+
}
|
|
1249
|
+
: undefined,
|
|
1250
|
+
body: new HereDocBodyImpl(this.source, tEnd, t.delimiterQuoted, this.depth),
|
|
1251
|
+
closing: undefined,
|
|
1252
|
+
};
|
|
1253
|
+
if (hasTarget)
|
|
1254
|
+
this.tok.registerHereDocTarget(r);
|
|
1255
|
+
return r;
|
|
1256
|
+
}
|
|
1257
|
+
const target = hasTarget
|
|
1258
|
+
? new WordImpl(this.source.slice(t.targetPos, t.targetEnd), t.targetPos, t.targetEnd, this.source, undefined, this.depth)
|
|
1259
|
+
: undefined;
|
|
1260
|
+
return t.value === "<<<"
|
|
1261
|
+
? { type: "HereString", pos: tPos, end: tEnd, operator: "<<<", descriptor, target }
|
|
1262
|
+
: { type: "Redirect", pos: tPos, end: tEnd, operator: REDIRECT_OPS[t.value] ?? ">", descriptor, target };
|
|
1263
|
+
}
|
|
1264
|
+
commandAsBody() {
|
|
1265
|
+
const cmd = this.command();
|
|
1266
|
+
if (cmd && cmd.type !== "Command" && cmd.type !== "Function" && cmd.type !== "Coproc")
|
|
1267
|
+
return cmd;
|
|
1268
|
+
this.error("expected compound command as function body", cmd?.pos ?? this.tok.getPos());
|
|
1269
|
+
return this.makeCompoundList(cmd ? [this.makeStatement(cmd)] : []);
|
|
1270
|
+
}
|
|
1271
|
+
readWord(ctx) {
|
|
1272
|
+
return this.toWord(this.tok.next(ctx));
|
|
1273
|
+
}
|
|
1274
|
+
toWord(tok) {
|
|
1275
|
+
const text = tok.raw ? tok.value : this.source.slice(tok.pos, tok.end);
|
|
1276
|
+
// Raw keyword-eligible words have no quotes or expansions to resolve.
|
|
1277
|
+
const source = tok.raw && tok.keywordEligible ? undefined : this.source;
|
|
1278
|
+
return new WordImpl(text, tok.pos, tok.end, source, undefined, this.depth);
|
|
1279
|
+
}
|
|
1280
|
+
toWordFromPosEnd(tok, pos, end) {
|
|
1281
|
+
if (tok.pos === pos && tok.end === end)
|
|
1282
|
+
return this.toWord(tok);
|
|
1283
|
+
return new WordImpl(this.source.slice(pos, end), pos, end, this.source, undefined, this.depth);
|
|
1284
|
+
}
|
|
1285
|
+
parseAssignment(token) {
|
|
1286
|
+
const text = token.raw ? token.value : this.source.slice(token.pos, token.end);
|
|
1287
|
+
return new AssignmentImpl(text, token.pos, token.end, this.source, token.assignmentOperatorPos, this.depth);
|
|
1288
|
+
}
|
|
1289
|
+
makeCompoundList(commands) {
|
|
1290
|
+
const p = this.tok.getPos();
|
|
1291
|
+
const pos = commands.length > 0 ? commands[0].pos : p;
|
|
1292
|
+
const end = commands.length > 0 ? commands[commands.length - 1].end : p;
|
|
1293
|
+
return { type: "CompoundList", pos, end, commands };
|
|
1294
|
+
}
|
|
1295
|
+
}
|