From a41e54b0c0fd6567cb6c7f7fe6b4eeb95574f146 Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Wed, 21 Oct 2026 16:50:14 +0200 Subject: [PATCH 01/14] chore(automation-utils): migrate to native ESM and drop ts-node Run automation scripts with Node's built-in type stripping instead of ts-node. Utils becomes "type": "module" with an exports map, package scripts are renamed to .mts, and the changelog parsers are generated as ES modules with peggy 5.1.0. --- .agents/skills/release-widget/SKILL.md | 2 +- .gitignore | 4 +- .../utils/{.prettierrc.js => .prettierrc.cjs} | 0 automation/utils/bin/rui-bump-version.ts | 10 ++--- automation/utils/bin/rui-changelog-helper.ts | 18 +++++---- automation/utils/bin/rui-changelog.ts | 10 ++--- automation/utils/bin/rui-check-changelogs.ts | 12 +++--- automation/utils/bin/rui-create-gh-release.ts | 12 +++--- .../utils/bin/rui-create-jira-version.ts | 4 +- .../utils/bin/rui-create-translation.ts | 8 ++-- automation/utils/bin/rui-generate-oss-sbom.ts | 6 +-- .../utils/bin/rui-generate-package-xml.ts | 12 +++--- .../utils/bin/rui-include-oss-in-artifact.ts | 10 ++--- .../utils/bin/rui-merge-changelogs-pr.ts | 4 +- automation/utils/bin/rui-oss-clearance.ts | 14 ++++--- automation/utils/bin/rui-package-info.ts | 4 +- automation/utils/bin/rui-prepare-release.ts | 16 ++++---- .../utils/bin/rui-publish-marketplace.ts | 6 +-- .../utils/bin/rui-update-changelog-module.ts | 8 ++-- .../utils/bin/rui-update-changelog-widget.ts | 6 +-- automation/utils/bin/rui-upload-readme-oss.ts | 6 +-- .../utils/bin/rui-verify-package-format.ts | 8 ++-- automation/utils/eslint.config.mjs | 2 +- automation/utils/index.ts | 6 +-- automation/utils/package.json | 30 ++++++++------ automation/utils/shell.ts | 2 +- automation/utils/src/api/contributor.ts | 4 +- automation/utils/src/build-config.ts | 2 +- automation/utils/src/bump-version.ts | 10 +++-- .../utils/src/changelog-parser/index.ts | 26 ++++++------ .../module/{module.d.ts => module.d.mts} | 4 +- .../widget/{widget.d.ts => widget.d.mts} | 2 +- .../utils/src/changelog-parser/types.ts | 2 +- automation/utils/src/changelog.ts | 6 +-- automation/utils/src/fetch.ts | 4 +- automation/utils/src/git.ts | 2 +- automation/utils/src/github.ts | 4 +- automation/utils/src/index.ts | 16 ++++---- automation/utils/src/jira.ts | 2 +- automation/utils/src/monorepo.ts | 10 +++-- automation/utils/src/mpk.ts | 8 ++-- automation/utils/src/oss-clearance.ts | 4 +- automation/utils/src/package-info.ts | 9 ++--- automation/utils/src/package-xml-v2/index.ts | 4 +- .../src/package-xml-v2/properties-xml.ts | 2 +- .../utils/src/prepare-release-helpers.ts | 16 ++++---- automation/utils/src/shell.ts | 9 +++-- automation/utils/src/steps.ts | 20 +++++----- .../utils/src/verify-widget-manifest.ts | 4 +- automation/utils/src/version.ts | 23 +++++++---- automation/utils/src/widget-file-xml.ts | 2 +- automation/utils/steps.ts | 2 +- automation/utils/tsconfig.json | 6 ++- automation/utils/utils.ts | 18 ++++----- docs/requirements/widget-to-module.md | 4 +- packages/modules/calendar/package.json | 6 +-- .../calendar/scripts/{build.ts => build.mts} | 0 .../scripts/push-update.mts} | 2 +- .../scripts/release.mts} | 2 +- packages/modules/data-widgets/package.json | 8 ++-- .../scripts/{build.ts => build.mts} | 4 +- .../scripts/push-update.mts} | 2 +- .../scripts/{release.ts => release.mts} | 4 +- .../scripts/{start.ts => start.mts} | 2 +- .../steps/{bundle-xlsx.ts => bundle-xlsx.mts} | 2 +- packages/modules/file-uploader/package.json | 6 +-- .../scripts/{build.ts => build.mts} | 0 .../scripts/push-update.mts} | 2 +- .../scripts/release.mts} | 2 +- packages/modules/google-tag/package.json | 6 +-- .../scripts/{build.ts => build.mts} | 0 .../scripts/push-update.mts} | 2 +- .../scripts/{release.ts => release.mts} | 2 +- packages/modules/pusher/package.json | 6 +-- .../pusher/scripts/{build.ts => build.mts} | 0 .../{push-update.ts => push-update.mts} | 0 .../scripts/{release.ts => release.mts} | 2 +- packages/modules/web-actions/package.json | 6 +-- .../scripts/{build.ts => build.mts} | 0 .../{push-update.ts => push-update.mts} | 0 .../scripts/{release.ts => release.mts} | 0 .../pluggableWidgets/charts-web/package.json | 4 +- .../scripts/{build.ts => build.mts} | 4 +- pnpm-lock.yaml | 40 ++++++++++++++----- 84 files changed, 304 insertions(+), 255 deletions(-) rename automation/utils/{.prettierrc.js => .prettierrc.cjs} (100%) rename automation/utils/src/changelog-parser/parser/module/{module.d.ts => module.d.mts} (83%) rename automation/utils/src/changelog-parser/parser/widget/{widget.d.ts => widget.d.mts} (88%) rename packages/modules/calendar/scripts/{build.ts => build.mts} (100%) rename packages/modules/{file-uploader/scripts/push-update.ts => calendar/scripts/push-update.mts} (91%) mode change 100755 => 100644 rename packages/modules/{file-uploader/scripts/release.ts => calendar/scripts/release.mts} (95%) mode change 100755 => 100644 rename packages/modules/data-widgets/scripts/{build.ts => build.mts} (89%) rename packages/modules/{google-tag/scripts/push-update.ts => data-widgets/scripts/push-update.mts} (91%) rename packages/modules/data-widgets/scripts/{release.ts => release.mts} (92%) rename packages/modules/data-widgets/scripts/{start.ts => start.mts} (97%) rename packages/modules/data-widgets/scripts/steps/{bundle-xlsx.ts => bundle-xlsx.mts} (91%) rename packages/modules/file-uploader/scripts/{build.ts => build.mts} (100%) rename packages/modules/{calendar/scripts/push-update.ts => file-uploader/scripts/push-update.mts} (91%) mode change 100644 => 100755 rename packages/modules/{calendar/scripts/release.ts => file-uploader/scripts/release.mts} (95%) mode change 100644 => 100755 rename packages/modules/google-tag/scripts/{build.ts => build.mts} (100%) rename packages/modules/{data-widgets/scripts/push-update.ts => google-tag/scripts/push-update.mts} (91%) rename packages/modules/google-tag/scripts/{release.ts => release.mts} (96%) rename packages/modules/pusher/scripts/{build.ts => build.mts} (100%) rename packages/modules/pusher/scripts/{push-update.ts => push-update.mts} (100%) rename packages/modules/pusher/scripts/{release.ts => release.mts} (97%) rename packages/modules/web-actions/scripts/{build.ts => build.mts} (100%) rename packages/modules/web-actions/scripts/{push-update.ts => push-update.mts} (100%) rename packages/modules/web-actions/scripts/{release.ts => release.mts} (100%) rename packages/pluggableWidgets/charts-web/scripts/{build.ts => build.mts} (94%) diff --git a/.agents/skills/release-widget/SKILL.md b/.agents/skills/release-widget/SKILL.md index d2d9152d5b..8cb0aaf4df 100644 --- a/.agents/skills/release-widget/SKILL.md +++ b/.agents/skills/release-widget/SKILL.md @@ -234,7 +234,7 @@ Teardown list (present all, confirm once, then execute): ## Common Mistakes -- **Writing inline `ts-node -e` scripts instead of using the packaged CLI helpers** — use `rui-package-info`, `rui-changelog`, `rui-bump-version`, `rui-create-jira-version`, `rui-generate-oss-sbom`, `rui-upload-readme-oss` (in `automation/utils/bin/`). Never reimplement ad hoc. +- **Writing inline `node -e` scripts instead of using the packaged CLI helpers** — use `rui-package-info`, `rui-changelog`, `rui-bump-version`, `rui-create-jira-version`, `rui-generate-oss-sbom`, `rui-upload-readme-oss` (in `automation/utils/bin/`). Never reimplement ad hoc. - **Working around a helper's refusal instead of fixing the input** — go back to Phase 0/2, don't bump the widget by hand. - **Publishing before the asset gate passes** — never `gh release edit --draft=false` without confirming both MPK and READMEOSS are attached. - **Escalating a 409 without checking run history first** — check `gh run list` for the tag first. diff --git a/.gitignore b/.gitignore index cfaaac8a27..9d28ee849f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,8 +20,8 @@ mendixProject **/pluggableWidgets/**/artifacts **/gh-*/release-notes.txt -**/automation/utils/**/parser/module/module.js -**/automation/utils/**/parser/widget/widget.js +**/automation/utils/**/parser/module/module.mjs +**/automation/utils/**/parser/widget/widget.mjs tests .turbo diff --git a/automation/utils/.prettierrc.js b/automation/utils/.prettierrc.cjs similarity index 100% rename from automation/utils/.prettierrc.js rename to automation/utils/.prettierrc.cjs diff --git a/automation/utils/bin/rui-bump-version.ts b/automation/utils/bin/rui-bump-version.ts index 784d49d107..c7846d641b 100755 --- a/automation/utils/bin/rui-bump-version.ts +++ b/automation/utils/bin/rui-bump-version.ts @@ -1,9 +1,9 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node -import { bumpPackageJson, bumpXml, hasPackageXml } from "../src/bump-version"; -import { resolvePackagePath } from "../src/monorepo"; -import { getPackageInfo, isReleasable } from "../src/package-info"; -import { Version, versionRegex } from "../src/version"; +import { bumpPackageJson, bumpXml, hasPackageXml } from "../src/bump-version.ts"; +import { resolvePackagePath } from "../src/monorepo.ts"; +import { getPackageInfo, isReleasable } from "../src/package-info.ts"; +import { Version, versionRegex } from "../src/version.ts"; async function bumpPackage(path: string, version: string): Promise { bumpPackageJson(path, version); diff --git a/automation/utils/bin/rui-changelog-helper.ts b/automation/utils/bin/rui-changelog-helper.ts index 153eeed8ab..1493ca2d2a 100644 --- a/automation/utils/bin/rui-changelog-helper.ts +++ b/automation/utils/bin/rui-changelog-helper.ts @@ -1,15 +1,17 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node -import { prompt } from "enquirer"; -import { getPackageInfo, PackageListing, selectPackage } from "../src"; +import enquirer from "enquirer"; import { getModuleChangelog, getWidgetChangelog, - ModuleChangelogFileWrapper, - WidgetChangelogFileWrapper -} from "../src/changelog-parser"; -import { LogSection } from "../src/changelog-parser/types"; -import { oraPromise } from "../src/cli-utils"; + type ModuleChangelogFileWrapper, + type WidgetChangelogFileWrapper +} from "../src/changelog-parser/index.ts"; +import type { LogSection } from "../src/changelog-parser/types.ts"; +import { oraPromise } from "../src/cli-utils.ts"; +import { getPackageInfo, type PackageListing, selectPackage } from "../src/index.ts"; + +const { prompt } = enquirer; async function getChangelogSections(): Promise { const sections: LogSection[] = []; diff --git a/automation/utils/bin/rui-changelog.ts b/automation/utils/bin/rui-changelog.ts index e2e0ec0159..7d7ddf3467 100644 --- a/automation/utils/bin/rui-changelog.ts +++ b/automation/utils/bin/rui-changelog.ts @@ -1,9 +1,9 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node -import { getPackageChangelog, getWidgetChangelog } from "../src/changelog-parser"; -import { SubComponentEntry } from "../src/changelog-parser/types"; -import { listPackages, resolvePackagePath } from "../src/monorepo"; -import { getPackageInfo, isReleasable } from "../src/package-info"; +import { getPackageChangelog, getWidgetChangelog } from "../src/changelog-parser/index.ts"; +import type { SubComponentEntry } from "../src/changelog-parser/types.ts"; +import { listPackages, resolvePackagePath } from "../src/monorepo.ts"; +import { getPackageInfo, isReleasable } from "../src/package-info.ts"; /** * A module's own CHANGELOG.md never carries unreleased subcomponent entries: diff --git a/automation/utils/bin/rui-check-changelogs.ts b/automation/utils/bin/rui-check-changelogs.ts index 37d580983a..f95acf7a1a 100644 --- a/automation/utils/bin/rui-check-changelogs.ts +++ b/automation/utils/bin/rui-check-changelogs.ts @@ -1,10 +1,10 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node -import { Version } from "../src"; -import { parse as parseModule } from "../src/changelog-parser/parser/module/module"; -import { parse as parseWidget } from "../src/changelog-parser/parser/widget/widget"; -import type { ModuleUnreleasedVersionEntry } from "../src/changelog-parser/types"; -import { exec } from "../src/shell"; +import { parse as parseModule } from "../src/changelog-parser/parser/module/module.mjs"; +import { parse as parseWidget } from "../src/changelog-parser/parser/widget/widget.mjs"; +import type { ModuleUnreleasedVersionEntry } from "../src/changelog-parser/types.ts"; +import { Version } from "../src/index.ts"; +import { exec } from "../src/shell.ts"; interface ChangelogChange { filePath: string; diff --git a/automation/utils/bin/rui-create-gh-release.ts b/automation/utils/bin/rui-create-gh-release.ts index 599f06c388..412269ffe0 100755 --- a/automation/utils/bin/rui-create-gh-release.ts +++ b/automation/utils/bin/rui-create-gh-release.ts @@ -1,10 +1,10 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { join, resolve } from "path"; -import { addRemoteWithAuthentication } from "../src"; -import { updateChangelogsAndCreatePR } from "../src/changelog"; -import { gh } from "../src/github"; -import { getPublishedInfo } from "../src/package-info"; -import { exec, find } from "../src/shell"; +import { updateChangelogsAndCreatePR } from "../src/changelog.ts"; +import { gh } from "../src/github.ts"; +import { addRemoteWithAuthentication } from "../src/index.ts"; +import { getPublishedInfo } from "../src/package-info.ts"; +import { exec, find } from "../src/shell.ts"; async function resolveChangelogBranch(releaseTag: string, remoteName: string): Promise { const { stdout } = await exec(`git rev-parse --abbrev-ref HEAD`, { stdio: "pipe" }); diff --git a/automation/utils/bin/rui-create-jira-version.ts b/automation/utils/bin/rui-create-jira-version.ts index e46e322189..f5bcf3f8ca 100755 --- a/automation/utils/bin/rui-create-jira-version.ts +++ b/automation/utils/bin/rui-create-jira-version.ts @@ -1,6 +1,6 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node -import { Jira } from "../src/jira"; +import { Jira } from "../src/jira.ts"; /** * Jira version creation has historically 404'd transiently and must never block diff --git a/automation/utils/bin/rui-create-translation.ts b/automation/utils/bin/rui-create-translation.ts index c4f427c44c..77337524d0 100755 --- a/automation/utils/bin/rui-create-translation.ts +++ b/automation/utils/bin/rui-create-translation.ts @@ -1,10 +1,10 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { mkdir, writeFile } from "fs/promises"; import path from "node:path"; import { dirname } from "path"; -import { getPackageFileContent, PackageSchema } from "../src"; -import { readXml } from "../src/package-xml"; -import { findCaptionsAndDescriptions, getWidgetXMLName, type Result } from "../src/widget-file-xml"; +import { getPackageFileContent, PackageSchema } from "../src/index.ts"; +import { readXml } from "../src/package-xml.ts"; +import { findCaptionsAndDescriptions, getWidgetXMLName, type Result } from "../src/widget-file-xml.ts"; async function main(): Promise { console.log(`Creating translation i18n format...`); const path = process.cwd(); diff --git a/automation/utils/bin/rui-generate-oss-sbom.ts b/automation/utils/bin/rui-generate-oss-sbom.ts index 017612f0d5..b327ff2861 100755 --- a/automation/utils/bin/rui-generate-oss-sbom.ts +++ b/automation/utils/bin/rui-generate-oss-sbom.ts @@ -1,13 +1,13 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { homedir } from "node:os"; import { join } from "node:path"; -import { gh } from "../src/github"; +import { gh } from "../src/github.ts"; import { createSBomGeneratorFolderStructure, generateSBomArtifactsInFolder, verifyAssetDigest -} from "../src/oss-clearance"; +} from "../src/oss-clearance.ts"; async function main(): Promise { const releaseTag = process.argv[2]; diff --git a/automation/utils/bin/rui-generate-package-xml.ts b/automation/utils/bin/rui-generate-package-xml.ts index 0f8e9a1430..40cbdb3400 100755 --- a/automation/utils/bin/rui-generate-package-xml.ts +++ b/automation/utils/bin/rui-generate-package-xml.ts @@ -1,10 +1,10 @@ -#!/usr/bin/env ts-node +#!/usr/bin/env node -import { writeClientPackageXml, ClientPackageXML } from "../src/package-xml-v2"; -import { getWidgetInfo } from "../src/package-info"; -import { readPropertiesFile } from "../src/package-xml-v2/properties-xml"; -import path from "node:path"; import { existsSync } from "node:fs"; +import path from "node:path"; +import { getWidgetInfo } from "../src/package-info.ts"; +import { type ClientPackageXML, writeClientPackageXml } from "../src/package-xml-v2/index.ts"; +import { readPropertiesFile } from "../src/package-xml-v2/properties-xml.ts"; async function generatePackageXml(): Promise { const widgetDir = process.cwd(); @@ -54,6 +54,6 @@ async function main() { } } -if (require.main === module) { +if (import.meta.main) { main(); } diff --git a/automation/utils/bin/rui-include-oss-in-artifact.ts b/automation/utils/bin/rui-include-oss-in-artifact.ts index ea00dab908..015df0a0b4 100755 --- a/automation/utils/bin/rui-include-oss-in-artifact.ts +++ b/automation/utils/bin/rui-include-oss-in-artifact.ts @@ -1,12 +1,12 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node -import { gh } from "../src/github"; -import { includeReadmeOssIntoMpk } from "../src/oss-clearance"; -import { rm } from "../src/shell"; import { mkdtemp, stat } from "node:fs/promises"; -import { join } from "node:path"; import { tmpdir } from "node:os"; +import { join } from "node:path"; import chalk from "chalk"; +import { gh } from "../src/github.ts"; +import { includeReadmeOssIntoMpk } from "../src/oss-clearance.ts"; +import { rm } from "../src/shell.ts"; /** * This script processes GitHub release artifacts to include READMEOSS HTML files into MPK files. diff --git a/automation/utils/bin/rui-merge-changelogs-pr.ts b/automation/utils/bin/rui-merge-changelogs-pr.ts index 8bb85d875f..77b67c6bf4 100755 --- a/automation/utils/bin/rui-merge-changelogs-pr.ts +++ b/automation/utils/bin/rui-merge-changelogs-pr.ts @@ -1,6 +1,6 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node -import { GitHub } from "../src/github"; +import { GitHub } from "../src/github.ts"; const ALLOWED_FILENAMES = new Set(["package.xml", "CHANGELOG.md", "package.json"]); diff --git a/automation/utils/bin/rui-oss-clearance.ts b/automation/utils/bin/rui-oss-clearance.ts index 111638cb94..ec5fea26c0 100755 --- a/automation/utils/bin/rui-oss-clearance.ts +++ b/automation/utils/bin/rui-oss-clearance.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node // Enable quiet mode for fetch calls to reduce logging noise process.env.FETCH_QUIET = "true"; @@ -6,8 +6,8 @@ process.env.FETCH_QUIET = "true"; import { homedir } from "node:os"; import { basename, join } from "path"; import chalk from "chalk"; -import { prompt } from "enquirer"; -import { gh, GitHubDraftRelease, GitHubReleaseAsset } from "../src/github"; +import enquirer from "enquirer"; +import { gh, type GitHubDraftRelease, type GitHubReleaseAsset } from "../src/github.ts"; import { computeSha256, createSBomGeneratorFolderStructure, @@ -16,7 +16,9 @@ import { getRecommendedReadmeOss, hasReadmeOssInAssets, includeReadmeOssIntoMpk -} from "../src/oss-clearance"; +} from "../src/oss-clearance.ts"; + +const { prompt } = enquirer; // ============================================================================ // Constants @@ -342,7 +344,7 @@ async function handleIncludeAsEmbeddedAction(release: GitHubDraftRelease, readme printProgressCheck("Download completed"); // Copy HTML to temp folder - const { cp } = await import("../src/shell"); + const { cp } = await import("../src/shell.ts"); await cp(readmeToInclude, htmlPath); // Embed HTML into MPK @@ -398,7 +400,7 @@ async function handleIncludeAsEmbeddedAction(release: GitHubDraftRelease, readme } finally { // Cleanup temp files printProgress("Cleaning up temporary files..."); - const { rm } = await import("../src/shell"); + const { rm } = await import("../src/shell.ts"); await rm("-rf", tmpFolder); } } diff --git a/automation/utils/bin/rui-package-info.ts b/automation/utils/bin/rui-package-info.ts index 3cd8f2ee78..840da196e9 100755 --- a/automation/utils/bin/rui-package-info.ts +++ b/automation/utils/bin/rui-package-info.ts @@ -1,6 +1,6 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node -import { getPackageInfo } from "../src/package-info"; +import { getPackageInfo } from "../src/package-info.ts"; async function main(): Promise { const path = process.cwd(); diff --git a/automation/utils/bin/rui-prepare-release.ts b/automation/utils/bin/rui-prepare-release.ts index 70fd950f88..35e763ff5d 100755 --- a/automation/utils/bin/rui-prepare-release.ts +++ b/automation/utils/bin/rui-prepare-release.ts @@ -1,11 +1,13 @@ -import { Jira, JiraVersion } from "../src/jira"; import chalk from "chalk"; -import { prompt } from "enquirer"; -import { bumpPackageJson, bumpXml, getNextVersion } from "../src/bump-version"; -import { exec } from "../src/shell"; -import { gh } from "../src/github"; -import { printGithubAuthHelp } from "../src/cli-utils"; -import { printPkgInformation, selectPackageV2, ensureMainBranch } from "../src/prepare-release-helpers"; +import enquirer from "enquirer"; +import { bumpPackageJson, bumpXml, getNextVersion } from "../src/bump-version.ts"; +import { printGithubAuthHelp } from "../src/cli-utils.ts"; +import { gh } from "../src/github.ts"; +import { Jira, type JiraVersion } from "../src/jira.ts"; +import { printPkgInformation, selectPackageV2, ensureMainBranch } from "../src/prepare-release-helpers.ts"; +import { exec } from "../src/shell.ts"; + +const { prompt } = enquirer; async function main(): Promise { try { diff --git a/automation/utils/bin/rui-publish-marketplace.ts b/automation/utils/bin/rui-publish-marketplace.ts index bf1ddfa437..5980adfa2c 100755 --- a/automation/utils/bin/rui-publish-marketplace.ts +++ b/automation/utils/bin/rui-publish-marketplace.ts @@ -1,9 +1,9 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import assert from "node:assert/strict"; -import { getPublishedInfo, gh } from "../src"; -import { createDraft, publishDraft } from "../src/api/contributor"; import chalk from "chalk"; +import { createDraft, publishDraft } from "../src/api/contributor.ts"; +import { getPublishedInfo, gh } from "../src/index.ts"; async function main(): Promise { console.log(`Getting package information...`); diff --git a/automation/utils/bin/rui-update-changelog-module.ts b/automation/utils/bin/rui-update-changelog-module.ts index 0a2af8e20c..4411df2fcf 100755 --- a/automation/utils/bin/rui-update-changelog-module.ts +++ b/automation/utils/bin/rui-update-changelog-module.ts @@ -1,9 +1,9 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { writeFile } from "fs/promises"; -import { getPackageInfo, listPackages, Version } from "../src"; -import { getModuleChangelog, getWidgetChangelog } from "../src/changelog-parser"; -import { SubComponentEntry } from "../src/changelog-parser/types"; +import { getModuleChangelog, getWidgetChangelog } from "../src/changelog-parser/index.ts"; +import type { SubComponentEntry } from "../src/changelog-parser/types.ts"; +import { getPackageInfo, listPackages, type Version } from "../src/index.ts"; function alreadyReleased(name: string, version: Version): string { return `[${name}] Failed to update changelog: version ${version.format()} already released`; diff --git a/automation/utils/bin/rui-update-changelog-widget.ts b/automation/utils/bin/rui-update-changelog-widget.ts index 2056568766..2273d159e2 100755 --- a/automation/utils/bin/rui-update-changelog-widget.ts +++ b/automation/utils/bin/rui-update-changelog-widget.ts @@ -1,8 +1,8 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { writeFile } from "fs/promises"; -import { getPackageInfo } from "../src"; -import { getWidgetChangelog } from "../src/changelog-parser"; +import { getWidgetChangelog } from "../src/changelog-parser/index.ts"; +import { getPackageInfo } from "../src/index.ts"; async function main(): Promise { const info = await getPackageInfo(process.cwd()); diff --git a/automation/utils/bin/rui-upload-readme-oss.ts b/automation/utils/bin/rui-upload-readme-oss.ts index a9cc0a8a51..a905ef67f3 100755 --- a/automation/utils/bin/rui-upload-readme-oss.ts +++ b/automation/utils/bin/rui-upload-readme-oss.ts @@ -1,8 +1,8 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { basename } from "node:path"; -import { gh } from "../src/github"; -import { findAllReadmeOssLocally, getRecommendedReadmeOss, hasReadmeOssInAssets } from "../src/oss-clearance"; +import { gh } from "../src/github.ts"; +import { findAllReadmeOssLocally, getRecommendedReadmeOss, hasReadmeOssInAssets } from "../src/oss-clearance.ts"; async function main(): Promise { const releaseTag = process.argv[2]; diff --git a/automation/utils/bin/rui-verify-package-format.ts b/automation/utils/bin/rui-verify-package-format.ts index 6be66d9548..8ab64b18b2 100755 --- a/automation/utils/bin/rui-verify-package-format.ts +++ b/automation/utils/bin/rui-verify-package-format.ts @@ -1,5 +1,6 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node +import chalk from "chalk"; import { ZodError } from "zod"; import { getModuleChangelog, @@ -9,9 +10,8 @@ import { ModulePackageSchema, PackageSchema, PublishedPackageSchema -} from "../src"; -import { verify as verifyWidget } from "../src/verify-widget-manifest"; -import chalk from "chalk"; +} from "../src/index.ts"; +import { verify as verifyWidget } from "../src/verify-widget-manifest.ts"; async function main(): Promise { const path = process.cwd(); diff --git a/automation/utils/eslint.config.mjs b/automation/utils/eslint.config.mjs index f676e2afb6..7712212a76 100644 --- a/automation/utils/eslint.config.mjs +++ b/automation/utils/eslint.config.mjs @@ -3,6 +3,6 @@ import config from "@mendix/eslint-config-web-widgets/widget-ts.mjs"; export default [ ...config, { - ignores: ["src/changelog-parser/parser/module/module.js", "src/changelog-parser/parser/widget/widget.js"] + ignores: ["src/changelog-parser/parser/module/module.mjs", "src/changelog-parser/parser/widget/widget.mjs"] } ]; diff --git a/automation/utils/index.ts b/automation/utils/index.ts index 99e22d6af5..324e72d93e 100644 --- a/automation/utils/index.ts +++ b/automation/utils/index.ts @@ -1,3 +1,3 @@ -export * as shell from "./shell"; -export * as utils from "./utils"; -export * as steps from "./steps"; +export * as shell from "./shell.ts"; +export * as utils from "./utils.ts"; +export * as steps from "./steps.ts"; diff --git a/automation/utils/package.json b/automation/utils/package.json index c74c4e1ca0..87d41475f8 100644 --- a/automation/utils/package.json +++ b/automation/utils/package.json @@ -22,26 +22,33 @@ "rui-upload-readme-oss": "bin/rui-upload-readme-oss.ts", "rui-verify-package-format": "bin/rui-verify-package-format.ts" }, - "types": "index.ts", - "main": "index.ts", + "type": "module", "files": [ "shell.ts", "steps.ts", "utils.ts", "tsconfig.json" ], + "exports": { + ".": "./index.ts", + "./shell": "./shell.ts", + "./steps": "./steps.ts", + "./utils": "./utils.ts", + "./tsconfig": "./tsconfig.json", + "./tsconfig.json": "./tsconfig.json" + }, "scripts": { - "changelog": "ts-node bin/rui-changelog-helper.ts", - "check-changelogs": "ts-node bin/rui-check-changelogs.ts", - "compile:parser:module": "peggy -o ./src/changelog-parser/parser/widget/widget.js ./src/changelog-parser/parser/widget/widget.pegjs", - "compile:parser:widget": "peggy -o ./src/changelog-parser/parser/module/module.js ./src/changelog-parser/parser/module/module.pegjs", + "changelog": "node bin/rui-changelog-helper.ts", + "check-changelogs": "node bin/rui-check-changelogs.ts", + "compile:parser:module": "peggy --format es -o ./src/changelog-parser/parser/widget/widget.mjs ./src/changelog-parser/parser/widget/widget.pegjs", + "compile:parser:widget": "peggy --format es -o ./src/changelog-parser/parser/module/module.mjs ./src/changelog-parser/parser/module/module.pegjs", "format": "prettier --write .", - "include-oss-in-artifact": "ts-node bin/rui-include-oss-in-artifact.ts", + "include-oss-in-artifact": "node bin/rui-include-oss-in-artifact.ts", "lint": "eslint --ext .jsx,.js,.ts,.tsx src/", - "merge-changelogs-pr": "ts-node bin/rui-merge-changelogs-pr.ts", - "oss-clearance": "ts-node bin/rui-oss-clearance.ts", + "merge-changelogs-pr": "node bin/rui-merge-changelogs-pr.ts", + "oss-clearance": "node bin/rui-oss-clearance.ts", "prepare": "pnpm run compile:parser:widget && pnpm run compile:parser:module && tsc", - "prepare-release": "ts-node bin/rui-prepare-release.ts", + "prepare-release": "node bin/rui-prepare-release.ts", "start": "tsc --watch" }, "devDependencies": { @@ -57,9 +64,8 @@ "glob": "^11.1.0", "node-fetch": "^2.7.0", "ora": "^5.4.1", - "peggy": "^1.2.0", + "peggy": "5.1.0", "shelljs": "^0.8.5", - "ts-node": "^10.9.1", "zod": "^3.25.76" } } diff --git a/automation/utils/shell.ts b/automation/utils/shell.ts index 4b5a049284..5d283ea17e 100644 --- a/automation/utils/shell.ts +++ b/automation/utils/shell.ts @@ -1 +1 @@ -export * from "./src/shell"; +export * from "./src/shell.ts"; diff --git a/automation/utils/src/api/contributor.ts b/automation/utils/src/api/contributor.ts index 6b1ad88075..7b2610084d 100644 --- a/automation/utils/src/api/contributor.ts +++ b/automation/utils/src/api/contributor.ts @@ -1,8 +1,8 @@ import assert from "node:assert/strict"; import chalk from "chalk"; import { z } from "zod"; -import { BodyInit, fetch } from "../fetch"; -import { Version } from "../version"; +import { type BodyInit, fetch } from "../fetch.ts"; +import { Version } from "../version.ts"; export interface CreateDraftSuccessResponse { App: App; diff --git a/automation/utils/src/build-config.ts b/automation/utils/src/build-config.ts index 0184b18772..af897e2c79 100644 --- a/automation/utils/src/build-config.ts +++ b/automation/utils/src/build-config.ts @@ -1,6 +1,6 @@ import { join } from "node:path"; import chalk from "chalk"; -import { getModuleInfo, getWidgetInfo, ModuleInfo, WidgetInfo } from "./package-info"; +import { getModuleInfo, getWidgetInfo, type ModuleInfo, type WidgetInfo } from "./package-info.ts"; export interface Output { dirs: Dirs; diff --git a/automation/utils/src/bump-version.ts b/automation/utils/src/bump-version.ts index c2a29f7c28..b44318b0ea 100644 --- a/automation/utils/src/bump-version.ts +++ b/automation/utils/src/bump-version.ts @@ -3,9 +3,11 @@ import { existsSync, promises as fs, readFileSync } from "fs"; import { join } from "path"; import { nextTick } from "process"; import chalk from "chalk"; -import { prompt } from "enquirer"; -import { PackageListing } from "./monorepo"; -import { Version } from "./version"; +import enquirer from "enquirer"; +import type { PackageListing } from "./monorepo.ts"; +import { Version } from "./version.ts"; + +const { prompt } = enquirer; export type BumpVersionType = "patch" | "minor" | "major" | string; @@ -38,7 +40,7 @@ export function hasPackageXml(path: string): boolean { export function bumpPackageJson(path: string, version: string): void { const packageJsonFile = join(path, "package.json"); const result = spawnSync("pnpm", ["version", version], { cwd: path, encoding: "utf8" }); - const written = JSON.parse(readFileSync(packageJsonFile, "utf8")).version; + const written = JSON.parse(readFileSync(packageJsonFile, "utf8")).version as string | undefined; if (written !== version) { throw new Error( diff --git a/automation/utils/src/changelog-parser/index.ts b/automation/utils/src/changelog-parser/index.ts index f3ef086fee..c48449fed3 100644 --- a/automation/utils/src/changelog-parser/index.ts +++ b/automation/utils/src/changelog-parser/index.ts @@ -1,10 +1,10 @@ import { readFileSync, writeFileSync } from "fs"; import { join } from "path"; -import { getPackageInfo } from "../package-info"; -import { Version } from "../version"; -import { parse as parseModuleChangelogFile } from "./parser/module/module"; -import { parse as parseWidgetChangelogFile } from "./parser/widget/widget"; -import { +import { getPackageInfo } from "../package-info.ts"; +import { Version } from "../version.ts"; +import { parse as parseModuleChangelogFile } from "./parser/module/module.mjs"; +import { parse as parseWidgetChangelogFile } from "./parser/widget/widget.mjs"; +import type { LogSection, ModuleChangelogFile, ModuleReleasedVersionEntry, @@ -15,7 +15,7 @@ import { UnreleasedVersionEntry, VersionEntry, WidgetChangelogFile -} from "./types"; +} from "./types.ts"; function formatHeader(header: string): string[] { return [ @@ -105,12 +105,11 @@ function mergeUnreleased(unreleased: T, sectio export class WidgetChangelogFileWrapper { changelog: WidgetChangelogFile; + changelogPath: string; - private constructor( - changelog: WidgetChangelogFile, - public changelogPath: string - ) { + private constructor(changelog: WidgetChangelogFile, changelogPath: string) { this.changelog = Object.freeze(changelog); + this.changelogPath = changelogPath; } save(): void { @@ -188,13 +187,12 @@ export class WidgetChangelogFileWrapper { export class ModuleChangelogFileWrapper { changelog: ModuleChangelogFile; moduleName: string; + changelogPath: string; - private constructor( - changelog: ModuleChangelogFile, - public changelogPath: string - ) { + private constructor(changelog: ModuleChangelogFile, changelogPath: string) { this.changelog = Object.freeze(changelog); this.moduleName = changelog.moduleName; + this.changelogPath = changelogPath; } save(): void { diff --git a/automation/utils/src/changelog-parser/parser/module/module.d.ts b/automation/utils/src/changelog-parser/parser/module/module.d.mts similarity index 83% rename from automation/utils/src/changelog-parser/parser/module/module.d.ts rename to automation/utils/src/changelog-parser/parser/module/module.d.mts index 162bcb38d3..f0adf301c7 100644 --- a/automation/utils/src/changelog-parser/parser/module/module.d.ts +++ b/automation/utils/src/changelog-parser/parser/module/module.d.mts @@ -1,5 +1,5 @@ -import { Version } from "../../../version"; -import { ModuleChangelogFile } from "../../types"; +import type { Version } from "../../../version.ts"; +import type { ModuleChangelogFile } from "../../types.ts"; declare interface Location { line: number; diff --git a/automation/utils/src/changelog-parser/parser/widget/widget.d.ts b/automation/utils/src/changelog-parser/parser/widget/widget.d.mts similarity index 88% rename from automation/utils/src/changelog-parser/parser/widget/widget.d.ts rename to automation/utils/src/changelog-parser/parser/widget/widget.d.mts index 046e895bd3..6cb1f8cdf7 100644 --- a/automation/utils/src/changelog-parser/parser/widget/widget.d.ts +++ b/automation/utils/src/changelog-parser/parser/widget/widget.d.mts @@ -1,4 +1,4 @@ -import { WidgetChangelogFile } from "../../types"; +import type { WidgetChangelogFile } from "../../types.ts"; declare interface Location { line: number; diff --git a/automation/utils/src/changelog-parser/types.ts b/automation/utils/src/changelog-parser/types.ts index 5ec8e39c2a..cef87eede7 100644 --- a/automation/utils/src/changelog-parser/types.ts +++ b/automation/utils/src/changelog-parser/types.ts @@ -1,4 +1,4 @@ -import { Version } from "../version"; +import type { Version } from "../version.ts"; export interface ReleasedVersionEntry { type: "normal"; diff --git a/automation/utils/src/changelog.ts b/automation/utils/src/changelog.ts index d9682f4b48..88d698f8f0 100644 --- a/automation/utils/src/changelog.ts +++ b/automation/utils/src/changelog.ts @@ -1,6 +1,6 @@ -import { gh } from "./github"; -import { PublishedInfo } from "./package-info"; -import { exec, popd, pushd } from "./shell"; +import { gh } from "./github.ts"; +import type { PublishedInfo } from "./package-info.ts"; +import { exec, popd, pushd } from "./shell.ts"; export async function updateChangelogsAndCreatePR( info: PublishedInfo, diff --git a/automation/utils/src/fetch.ts b/automation/utils/src/fetch.ts index 37cedb68da..2c46689774 100644 --- a/automation/utils/src/fetch.ts +++ b/automation/utils/src/fetch.ts @@ -1,6 +1,6 @@ -import nodefetch, { BodyInit, RequestInit } from "node-fetch"; +import nodefetch, { type BodyInit, type RequestInit } from "node-fetch"; -export { BodyInit } from "node-fetch"; +export type { BodyInit } from "node-fetch"; export async function fetch( method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", diff --git a/automation/utils/src/git.ts b/automation/utils/src/git.ts index ef2559e4dd..7d3a151201 100644 --- a/automation/utils/src/git.ts +++ b/automation/utils/src/git.ts @@ -1,4 +1,4 @@ -import { exec } from "./shell"; +import { exec } from "./shell.ts"; function getGHRepoAuthUrl(repoUrl: string): string { const url = new URL(repoUrl); diff --git a/automation/utils/src/github.ts b/automation/utils/src/github.ts index 01b0e1d50b..12016f69f9 100644 --- a/automation/utils/src/github.ts +++ b/automation/utils/src/github.ts @@ -3,8 +3,8 @@ import { mkdtemp, readFile, writeFile } from "fs/promises"; import { join } from "path"; import { pipeline } from "stream/promises"; import nodefetch from "node-fetch"; -import { fetch } from "./fetch"; -import { exec } from "./shell"; +import { fetch } from "./fetch.ts"; +import { exec } from "./shell.ts"; export interface GitHubPR { number: number; diff --git a/automation/utils/src/index.ts b/automation/utils/src/index.ts index 8e405bb4e8..734f42cc1e 100644 --- a/automation/utils/src/index.ts +++ b/automation/utils/src/index.ts @@ -1,8 +1,8 @@ -export * from "./version"; -export * from "./package-info"; -export * from "./git"; -export * from "./github"; -export * from "./mpk"; -export * from "./changelog-parser"; -export * from "./monorepo"; -export * from "./build-config"; +export * from "./version.ts"; +export * from "./package-info.ts"; +export * from "./git.ts"; +export * from "./github.ts"; +export * from "./mpk.ts"; +export * from "./changelog-parser/index.ts"; +export * from "./monorepo.ts"; +export * from "./build-config.ts"; diff --git a/automation/utils/src/jira.ts b/automation/utils/src/jira.ts index cf6a63149f..83fbe7451d 100644 --- a/automation/utils/src/jira.ts +++ b/automation/utils/src/jira.ts @@ -1,4 +1,4 @@ -import nodefetch, { RequestInit } from "node-fetch"; +import nodefetch, { type RequestInit } from "node-fetch"; export interface JiraVersion { id: string; diff --git a/automation/utils/src/monorepo.ts b/automation/utils/src/monorepo.ts index b0203219d9..dcfb4f6ed5 100644 --- a/automation/utils/src/monorepo.ts +++ b/automation/utils/src/monorepo.ts @@ -1,6 +1,8 @@ -import { prompt } from "enquirer"; -import { oraPromise } from "./cli-utils"; -import { cp, exec, find, mkdir } from "./shell"; +import enquirer from "enquirer"; +import { oraPromise } from "./cli-utils.ts"; +import { cp, exec, find, mkdir } from "./shell.ts"; + +const { prompt } = enquirer; type DependencyName = string; @@ -24,7 +26,7 @@ export async function listPackages(packageNames: string[]): Promise `--filter ${name}`); const command = [pnpmCommand, ...filters].join(" "); const result = (await exec(command, { stdio: "pipe" })).stdout.trim(); - const data = JSON.parse(result !== "" ? result : "[]"); + const data = JSON.parse(result !== "" ? result : "[]") as PackageListing[]; return data; } diff --git a/automation/utils/src/mpk.ts b/automation/utils/src/mpk.ts index 93c8bae338..d997cb3796 100644 --- a/automation/utils/src/mpk.ts +++ b/automation/utils/src/mpk.ts @@ -1,13 +1,13 @@ import { basename, join } from "path"; -import { ModuleInfo } from "./package-info"; -import { exec, find } from "./shell"; -import { Version } from "./version"; +import type { ModuleInfo } from "./package-info.ts"; +import { exec, find } from "./shell.ts"; +import type { Version } from "./version.ts"; async function ensureMxBuildDockerImageExists(version: string): Promise { const existingImages = (await exec(`docker image ls -q mxbuild:${version}`, { stdio: "pipe" })).stdout.trim(); if (!existingImages) { console.log(`Creating new mxbuild:${version} docker image...`); - const dockerfilePath = join(__dirname, "../docker/mxbuild.Dockerfile"); + const dockerfilePath = join(import.meta.dirname, "../docker/mxbuild.Dockerfile"); await exec( `docker build -f ${dockerfilePath} ` + `--build-arg MENDIX_VERSION=${version} ` + diff --git a/automation/utils/src/oss-clearance.ts b/automation/utils/src/oss-clearance.ts index 4731289f7c..65cf1f56eb 100644 --- a/automation/utils/src/oss-clearance.ts +++ b/automation/utils/src/oss-clearance.ts @@ -5,8 +5,8 @@ import { homedir, tmpdir } from "node:os"; import { pipeline } from "node:stream/promises"; import { basename, join, parse } from "path"; import { globSync } from "glob"; -import { GitHubReleaseAsset } from "./github"; -import { chmod, cp, exec, mkdir, mv, rm, unzip, zip } from "./shell"; +import type { GitHubReleaseAsset } from "./github.ts"; +import { chmod, cp, exec, mkdir, mv, rm, unzip, zip } from "./shell.ts"; export async function computeSha256(filePath: string): Promise { const hash = createHash("sha256"); diff --git a/automation/utils/src/package-info.ts b/automation/utils/src/package-info.ts index f45f6cfd2c..9f78e9b76f 100644 --- a/automation/utils/src/package-info.ts +++ b/automation/utils/src/package-info.ts @@ -1,7 +1,7 @@ -import { access } from "fs/promises"; +import { access, readFile } from "fs/promises"; import { join } from "path"; import { z } from "zod"; -import { versionSchema } from "./version"; +import { versionSchema } from "./version.ts"; export interface PackageJsonFileContent { name?: string; @@ -142,10 +142,7 @@ export async function getPackageFileContent(dirPath: string): Promise { - return module.default as PackageJsonFileContent; - }); - return result; + return JSON.parse(await readFile(pkgPath, "utf8")) as PackageJsonFileContent; } catch (error) { console.log(error); console.error(`ERROR: Path does not exist: ${pkgPath}`); diff --git a/automation/utils/src/package-xml-v2/index.ts b/automation/utils/src/package-xml-v2/index.ts index 01f9e9f865..6ba530b587 100644 --- a/automation/utils/src/package-xml-v2/index.ts +++ b/automation/utils/src/package-xml-v2/index.ts @@ -1,7 +1,7 @@ import { readFile, writeFile } from "fs/promises"; import { XMLBuilder, XMLParser } from "fast-xml-parser"; -import { Version, VersionString } from "../version"; -import { ClientModulePackageFile } from "./schema"; +import { Version, type VersionString } from "../version.ts"; +import { ClientModulePackageFile } from "./schema.ts"; export function xmlTextToXmlJson(xmlText: string | Buffer): unknown { const parser = new XMLParser({ ignoreAttributes: false }); diff --git a/automation/utils/src/package-xml-v2/properties-xml.ts b/automation/utils/src/package-xml-v2/properties-xml.ts index be2ba3466c..5f4d1845b8 100644 --- a/automation/utils/src/package-xml-v2/properties-xml.ts +++ b/automation/utils/src/package-xml-v2/properties-xml.ts @@ -1,6 +1,6 @@ import { readFile } from "node:fs/promises"; import { z } from "zod"; -import { xmlTextToXmlJson } from "./index"; +import { xmlTextToXmlJson } from "./index.ts"; export const PropertiesXMLFile = z.object({ "?xml": z.object({ diff --git a/automation/utils/src/prepare-release-helpers.ts b/automation/utils/src/prepare-release-helpers.ts index 91bbc45741..2b315b5594 100644 --- a/automation/utils/src/prepare-release-helpers.ts +++ b/automation/utils/src/prepare-release-helpers.ts @@ -1,14 +1,16 @@ import chalk from "chalk"; -import { prompt } from "enquirer"; +import enquirer from "enquirer"; import { getModuleChangelog, getPackageChangelog, - ModuleChangelogFileWrapper, - WidgetChangelogFileWrapper -} from "./changelog-parser"; -import { listPackages, PackageListing } from "./monorepo"; -import { getModuleInfo, getPackageInfo, getWidgetInfo, ModuleInfo, WidgetInfo } from "./package-info"; -import { exec } from "./shell"; + type ModuleChangelogFileWrapper, + type WidgetChangelogFileWrapper +} from "./changelog-parser/index.ts"; +import { listPackages, type PackageListing } from "./monorepo.ts"; +import { getModuleInfo, getPackageInfo, getWidgetInfo, type ModuleInfo, type WidgetInfo } from "./package-info.ts"; +import { exec } from "./shell.ts"; + +const { prompt } = enquirer; type WidgetPkg = { type: "widget"; diff --git a/automation/utils/src/shell.ts b/automation/utils/src/shell.ts index 6567882c53..d447c54297 100644 --- a/automation/utils/src/shell.ts +++ b/automation/utils/src/shell.ts @@ -1,13 +1,16 @@ import crossZip from "cross-zip"; import execa from "execa"; -import { config, ls, popd, pushd } from "shelljs"; +import shelljs from "shelljs"; + +// shelljs is CommonJS, so named imports are not available under native ESM +const { config } = shelljs; // Enable fast fail for all shelljs commands config.fatal = true; // Export all except exec as we will execa to execute commands // KNOWN ISSUES: // - mv don't throw error https://github.com/shelljs/shelljs/issues/878 -export { +export const { cat, cd, chmod, @@ -37,7 +40,7 @@ export { touch, uniq, which -} from "shelljs"; +} = shelljs; export { config as shelljsConfig }; export function exec(command: string, options?: execa.Options): execa.ExecaChildProcess { diff --git a/automation/utils/src/steps.ts b/automation/utils/src/steps.ts index 67fa466e48..0b015f274b 100644 --- a/automation/utils/src/steps.ts +++ b/automation/utils/src/steps.ts @@ -2,18 +2,18 @@ import { readFile, writeFile } from "node:fs/promises"; import { dirname, join, parse, relative, resolve } from "path"; import chalk from "chalk"; import { - CommonBuildConfig, + type CommonBuildConfig, getModuleConfigs, getWidgetConfigs, - ModuleBuildConfig, - WidgetBuildConfig -} from "./build-config"; -import { cloneRepo, cloneRepoShallow, setLocalGitUserInfo } from "./git"; -import { copyMpkFiles, getMpkPaths } from "./monorepo"; -import { createModuleMpkInDocker } from "./mpk"; -import { ModuleInfo, PackageInfo, WidgetInfo } from "./package-info"; -import { addFilesToPackageXml, PackageType } from "./package-xml"; -import { chmod, cp, ensureFileExists, exec, find, mkdir, popd, pushd, rm, unzip, zip } from "./shell"; + type ModuleBuildConfig, + type WidgetBuildConfig +} from "./build-config.ts"; +import { cloneRepo, cloneRepoShallow, setLocalGitUserInfo } from "./git.ts"; +import { copyMpkFiles, getMpkPaths } from "./monorepo.ts"; +import { createModuleMpkInDocker } from "./mpk.ts"; +import type { ModuleInfo, PackageInfo, WidgetInfo } from "./package-info.ts"; +import { addFilesToPackageXml, type PackageType } from "./package-xml.ts"; +import { chmod, cp, ensureFileExists, exec, find, mkdir, popd, pushd, rm, unzip, zip } from "./shell.ts"; type Step = (params: { info: Info; config: Config }) => Promise; diff --git a/automation/utils/src/verify-widget-manifest.ts b/automation/utils/src/verify-widget-manifest.ts index 90203ecf0a..a5ac73a474 100644 --- a/automation/utils/src/verify-widget-manifest.ts +++ b/automation/utils/src/verify-widget-manifest.ts @@ -1,5 +1,5 @@ -import { WidgetPackage, WidgetPackageSchema } from "./package-info"; -import { ClientModulePackageFile, readPackageXml } from "./package-xml"; +import { type WidgetPackage, WidgetPackageSchema } from "./package-info.ts"; +import { ClientModulePackageFile, readPackageXml } from "./package-xml.ts"; type ParsedManifests = [WidgetPackage, ClientModulePackageFile]; diff --git a/automation/utils/src/version.ts b/automation/utils/src/version.ts index e0d1dbe7ff..3ee73a6049 100644 --- a/automation/utils/src/version.ts +++ b/automation/utils/src/version.ts @@ -11,17 +11,24 @@ export const versionRegex = new RegExp(`^${g1}\\.${g2}\\.${g3}(?:\\.${g4})?$`, " const versionSchemaBase = z.string().regex(versionRegex); -export const versionStringSchema = versionSchemaBase.transform(str => str); -export const versionTuple = versionSchemaBase.transform(str => str.split(".").map(p => parseInt(p, 10))); +export const versionStringSchema = versionSchemaBase.transform(str => str as VersionString); +export const versionTuple = versionSchemaBase.transform( + str => str.split(".").map(p => parseInt(p, 10)) as VersionTuple +); export const versionSchema = versionSchemaBase.transform(str => Version.fromString(str as VersionString)); export class Version { - constructor( - public readonly major: number, - public readonly minor: number, - public readonly patch: number, - public readonly build: number | undefined - ) {} + readonly major: number; + readonly minor: number; + readonly patch: number; + readonly build: number | undefined; + + constructor(major: number, minor: number, patch: number, build: number | undefined) { + this.major = major; + this.minor = minor; + this.patch = patch; + this.build = build; + } bumpPatch(): Version { return new Version(this.major, this.minor, this.patch + 1, undefined); diff --git a/automation/utils/src/widget-file-xml.ts b/automation/utils/src/widget-file-xml.ts index 0105997794..08501069a3 100644 --- a/automation/utils/src/widget-file-xml.ts +++ b/automation/utils/src/widget-file-xml.ts @@ -1,4 +1,4 @@ -import { readPackageXml } from "./package-xml"; +import { readPackageXml } from "./package-xml.ts"; export interface Result { [key: string]: string; } diff --git a/automation/utils/steps.ts b/automation/utils/steps.ts index 1f165d5751..2eeca1ca87 100644 --- a/automation/utils/steps.ts +++ b/automation/utils/steps.ts @@ -1 +1 @@ -export * from "./src/steps"; +export * from "./src/steps.ts"; diff --git a/automation/utils/tsconfig.json b/automation/utils/tsconfig.json index 813a378e5b..e6a78385d4 100644 --- a/automation/utils/tsconfig.json +++ b/automation/utils/tsconfig.json @@ -2,8 +2,12 @@ "include": ["./src", "./bin"], "compilerOptions": { "lib": ["ES2022"], - "module": "CommonJS", + "module": "NodeNext", + "moduleResolution": "NodeNext", "target": "ES2022", + "allowImportingTsExtensions": true, + "erasableSyntaxOnly": true, + "verbatimModuleSyntax": true, "types": ["node"], "outDir": "./dist", "strict": true, diff --git a/automation/utils/utils.ts b/automation/utils/utils.ts index 961a098982..80a4c89ee7 100644 --- a/automation/utils/utils.ts +++ b/automation/utils/utils.ts @@ -1,9 +1,9 @@ -export * from "./src/version"; -export * from "./src/package-info"; -export * from "./src/git"; -export * from "./src/github"; -export * from "./src/mpk"; -export * from "./src/changelog-parser"; -export * from "./src/monorepo"; -export * from "./src/build-config"; -export * from "./src/package-xml"; +export * from "./src/version.ts"; +export * from "./src/package-info.ts"; +export * from "./src/git.ts"; +export * from "./src/github.ts"; +export * from "./src/mpk.ts"; +export * from "./src/changelog-parser/index.ts"; +export * from "./src/monorepo.ts"; +export * from "./src/build-config.ts"; +export * from "./src/package-xml.ts"; diff --git a/docs/requirements/widget-to-module.md b/docs/requirements/widget-to-module.md index 390857da4d..178ad0ca96 100644 --- a/docs/requirements/widget-to-module.md +++ b/docs/requirements/widget-to-module.md @@ -83,8 +83,8 @@ packages/modules/calendar/ "branchName": "calendar-web" }, "scripts": { - "build:module": "ts-node --project scripts/tsconfig.json scripts/build.ts", - "release:module": "ts-node --project scripts/tsconfig.json scripts/release.ts" + "build:module": "node scripts/build.mts", + "release:module": "node scripts/release.mts" } } ``` diff --git a/packages/modules/calendar/package.json b/packages/modules/calendar/package.json index aab985c51f..44b6264740 100644 --- a/packages/modules/calendar/package.json +++ b/packages/modules/calendar/package.json @@ -28,11 +28,11 @@ "branchName": "calendar-web" }, "scripts": { - "build:module": "ts-node --project scripts/tsconfig.json scripts/build.ts", + "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", "publish-marketplace": "rui-publish-marketplace", - "push-update": "ts-node --project scripts/tsconfig.json scripts/push-update.ts", - "release:module": "ts-node --project scripts/tsconfig.json scripts/release.ts", + "push-update": "node scripts/push-update.mts", + "release:module": "node scripts/release.mts", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/calendar/scripts/build.ts b/packages/modules/calendar/scripts/build.mts similarity index 100% rename from packages/modules/calendar/scripts/build.ts rename to packages/modules/calendar/scripts/build.mts diff --git a/packages/modules/file-uploader/scripts/push-update.ts b/packages/modules/calendar/scripts/push-update.mts old mode 100755 new mode 100644 similarity index 91% rename from packages/modules/file-uploader/scripts/push-update.ts rename to packages/modules/calendar/scripts/push-update.mts index a593a1bcfd..a91354cc55 --- a/packages/modules/file-uploader/scripts/push-update.ts +++ b/packages/modules/calendar/scripts/push-update.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { pushUpdateToTestProject, runModuleSteps } from "@mendix/automation-utils/steps"; diff --git a/packages/modules/file-uploader/scripts/release.ts b/packages/modules/calendar/scripts/release.mts old mode 100755 new mode 100644 similarity index 95% rename from packages/modules/file-uploader/scripts/release.ts rename to packages/modules/calendar/scripts/release.mts index d8ff81f729..7e56eb0fea --- a/packages/modules/file-uploader/scripts/release.ts +++ b/packages/modules/calendar/scripts/release.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { addWidgetsToMpk, diff --git a/packages/modules/data-widgets/package.json b/packages/modules/data-widgets/package.json index 4d229e0695..4f9e17c1e4 100644 --- a/packages/modules/data-widgets/package.json +++ b/packages/modules/data-widgets/package.json @@ -39,15 +39,15 @@ "scripts": { "build:deps": "turbo run build --filter=@mendix/data-widgets^...", "build:include-deps": "pnpm run build:deps && pnpm run build:module", - "build:module": "ts-node --project scripts/tsconfig.json scripts/build.ts", + "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", "create-module-mpk": "turbo release:module --filter @mendix/data-widgets", "format": "prettier --ignore-path ./node_modules/@mendix/prettier-config-web-widgets/global-prettierignore --write .", "lint": "tsc --project scripts/tsconfig.json && eslint . package.json", "publish-marketplace": "rui-publish-marketplace", - "push-update": "ts-node --project scripts/tsconfig.json scripts/push-update.ts", - "release:module": "ts-node --project scripts/tsconfig.json scripts/release.ts", - "start": "ts-node --project scripts/tsconfig.json scripts/start.ts", + "push-update": "node scripts/push-update.mts", + "release:module": "node scripts/release.mts", + "start": "node scripts/start.mts", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/data-widgets/scripts/build.ts b/packages/modules/data-widgets/scripts/build.mts similarity index 89% rename from packages/modules/data-widgets/scripts/build.ts rename to packages/modules/data-widgets/scripts/build.mts index 688d3812fd..6a6a6b4a5e 100755 --- a/packages/modules/data-widgets/scripts/build.ts +++ b/packages/modules/data-widgets/scripts/build.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { copyActionsFiles, @@ -9,7 +9,7 @@ import { writeModuleVersion } from "@mendix/automation-utils/steps"; -import { bundleXLSX } from "./steps/bundle-xlsx"; +import { bundleXLSX } from "./steps/bundle-xlsx.mts"; async function main(): Promise { await runModuleSteps({ diff --git a/packages/modules/google-tag/scripts/push-update.ts b/packages/modules/data-widgets/scripts/push-update.mts similarity index 91% rename from packages/modules/google-tag/scripts/push-update.ts rename to packages/modules/data-widgets/scripts/push-update.mts index a593a1bcfd..a91354cc55 100755 --- a/packages/modules/google-tag/scripts/push-update.ts +++ b/packages/modules/data-widgets/scripts/push-update.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { pushUpdateToTestProject, runModuleSteps } from "@mendix/automation-utils/steps"; diff --git a/packages/modules/data-widgets/scripts/release.ts b/packages/modules/data-widgets/scripts/release.mts similarity index 92% rename from packages/modules/data-widgets/scripts/release.ts rename to packages/modules/data-widgets/scripts/release.mts index bc29ec0a2c..ea305c703a 100755 --- a/packages/modules/data-widgets/scripts/release.ts +++ b/packages/modules/data-widgets/scripts/release.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { addWidgetsToMpk, @@ -14,7 +14,7 @@ import { writeModuleVersion } from "@mendix/automation-utils/steps"; -import { bundleXLSX } from "./steps/bundle-xlsx"; +import { bundleXLSX } from "./steps/bundle-xlsx.mts"; async function main(): Promise { await runModuleSteps({ diff --git a/packages/modules/data-widgets/scripts/start.ts b/packages/modules/data-widgets/scripts/start.mts similarity index 97% rename from packages/modules/data-widgets/scripts/start.ts rename to packages/modules/data-widgets/scripts/start.mts index 8e85516b25..f3d5f796cd 100755 --- a/packages/modules/data-widgets/scripts/start.ts +++ b/packages/modules/data-widgets/scripts/start.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { join } from "path"; import concurrently from "concurrently"; diff --git a/packages/modules/data-widgets/scripts/steps/bundle-xlsx.ts b/packages/modules/data-widgets/scripts/steps/bundle-xlsx.mts similarity index 91% rename from packages/modules/data-widgets/scripts/steps/bundle-xlsx.ts rename to packages/modules/data-widgets/scripts/steps/bundle-xlsx.mts index b83a48141d..78c087b49b 100644 --- a/packages/modules/data-widgets/scripts/steps/bundle-xlsx.ts +++ b/packages/modules/data-widgets/scripts/steps/bundle-xlsx.mts @@ -3,7 +3,7 @@ import resolve from "@rollup/plugin-node-resolve"; import terser from "@rollup/plugin-terser"; import * as rollup from "rollup"; import type { InputOptions, OutputOptions } from "rollup"; -import { copyActionsFiles, logStep, ModuleStepParams } from "@mendix/automation-utils/steps"; +import { copyActionsFiles, logStep, type ModuleStepParams } from "@mendix/automation-utils/steps"; type Entry = { getInputOptions: (params: ModuleStepParams) => InputOptions; diff --git a/packages/modules/file-uploader/package.json b/packages/modules/file-uploader/package.json index c710ac83cf..6298268715 100644 --- a/packages/modules/file-uploader/package.json +++ b/packages/modules/file-uploader/package.json @@ -28,11 +28,11 @@ "branchName": "fileuploader-web" }, "scripts": { - "build:module": "ts-node --project scripts/tsconfig.json scripts/build.ts", + "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", "publish-marketplace": "rui-publish-marketplace", - "push-update": "ts-node --project scripts/tsconfig.json scripts/push-update.ts", - "release:module": "ts-node --project scripts/tsconfig.json scripts/release.ts", + "push-update": "node scripts/push-update.mts", + "release:module": "node scripts/release.mts", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/file-uploader/scripts/build.ts b/packages/modules/file-uploader/scripts/build.mts similarity index 100% rename from packages/modules/file-uploader/scripts/build.ts rename to packages/modules/file-uploader/scripts/build.mts diff --git a/packages/modules/calendar/scripts/push-update.ts b/packages/modules/file-uploader/scripts/push-update.mts old mode 100644 new mode 100755 similarity index 91% rename from packages/modules/calendar/scripts/push-update.ts rename to packages/modules/file-uploader/scripts/push-update.mts index a593a1bcfd..a91354cc55 --- a/packages/modules/calendar/scripts/push-update.ts +++ b/packages/modules/file-uploader/scripts/push-update.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { pushUpdateToTestProject, runModuleSteps } from "@mendix/automation-utils/steps"; diff --git a/packages/modules/calendar/scripts/release.ts b/packages/modules/file-uploader/scripts/release.mts old mode 100644 new mode 100755 similarity index 95% rename from packages/modules/calendar/scripts/release.ts rename to packages/modules/file-uploader/scripts/release.mts index d8ff81f729..7e56eb0fea --- a/packages/modules/calendar/scripts/release.ts +++ b/packages/modules/file-uploader/scripts/release.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { addWidgetsToMpk, diff --git a/packages/modules/google-tag/package.json b/packages/modules/google-tag/package.json index 0becbba1aa..f3a4645ac7 100644 --- a/packages/modules/google-tag/package.json +++ b/packages/modules/google-tag/package.json @@ -28,11 +28,11 @@ "branchName": "google-tag-web" }, "scripts": { - "build:module": "ts-node --project scripts/tsconfig.json scripts/build.ts", + "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", "publish-marketplace": "rui-publish-marketplace", - "push-update": "ts-node --project scripts/tsconfig.json scripts/push-update.ts", - "release:module": "ts-node --project scripts/tsconfig.json scripts/release.ts", + "push-update": "node scripts/push-update.mts", + "release:module": "node scripts/release.mts", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/google-tag/scripts/build.ts b/packages/modules/google-tag/scripts/build.mts similarity index 100% rename from packages/modules/google-tag/scripts/build.ts rename to packages/modules/google-tag/scripts/build.mts diff --git a/packages/modules/data-widgets/scripts/push-update.ts b/packages/modules/google-tag/scripts/push-update.mts similarity index 91% rename from packages/modules/data-widgets/scripts/push-update.ts rename to packages/modules/google-tag/scripts/push-update.mts index a593a1bcfd..a91354cc55 100755 --- a/packages/modules/data-widgets/scripts/push-update.ts +++ b/packages/modules/google-tag/scripts/push-update.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { pushUpdateToTestProject, runModuleSteps } from "@mendix/automation-utils/steps"; diff --git a/packages/modules/google-tag/scripts/release.ts b/packages/modules/google-tag/scripts/release.mts similarity index 96% rename from packages/modules/google-tag/scripts/release.ts rename to packages/modules/google-tag/scripts/release.mts index 99a1db7ec4..f30f3fecf0 100755 --- a/packages/modules/google-tag/scripts/release.ts +++ b/packages/modules/google-tag/scripts/release.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { addWidgetsToMpk, diff --git a/packages/modules/pusher/package.json b/packages/modules/pusher/package.json index 861f6acc97..4b52839f9a 100644 --- a/packages/modules/pusher/package.json +++ b/packages/modules/pusher/package.json @@ -29,11 +29,11 @@ "branchName": "pusher-web" }, "scripts": { - "build:module": "ts-node --project scripts/tsconfig.json scripts/build.ts", + "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", "publish-marketplace": "rui-publish-marketplace", - "push-update": "ts-node --project scripts/tsconfig.json scripts/push-update.ts", - "release:module": "ts-node --project scripts/tsconfig.json scripts/release.ts", + "push-update": "node scripts/push-update.mts", + "release:module": "node scripts/release.mts", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/pusher/scripts/build.ts b/packages/modules/pusher/scripts/build.mts similarity index 100% rename from packages/modules/pusher/scripts/build.ts rename to packages/modules/pusher/scripts/build.mts diff --git a/packages/modules/pusher/scripts/push-update.ts b/packages/modules/pusher/scripts/push-update.mts similarity index 100% rename from packages/modules/pusher/scripts/push-update.ts rename to packages/modules/pusher/scripts/push-update.mts diff --git a/packages/modules/pusher/scripts/release.ts b/packages/modules/pusher/scripts/release.mts similarity index 97% rename from packages/modules/pusher/scripts/release.ts rename to packages/modules/pusher/scripts/release.mts index 5e07595ff4..662aef21b7 100644 --- a/packages/modules/pusher/scripts/release.ts +++ b/packages/modules/pusher/scripts/release.mts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { addTestProjectWidgetsToMpk, diff --git a/packages/modules/web-actions/package.json b/packages/modules/web-actions/package.json index 4578ecf917..6d35f61f02 100644 --- a/packages/modules/web-actions/package.json +++ b/packages/modules/web-actions/package.json @@ -24,13 +24,13 @@ "branchName": "main" }, "scripts": { - "build:module": "ts-node --project scripts/tsconfig.json scripts/build.ts", + "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", "format": "echo 'Skip as actions use special format'", "lint": "eslint --ext .js src/", "publish-marketplace": "rui-publish-marketplace", - "push-update": "ts-node --project scripts/tsconfig.json scripts/push-update.ts", - "release:module": "ts-node --project scripts/tsconfig.json scripts/release.ts", + "push-update": "node scripts/push-update.mts", + "release:module": "node scripts/release.mts", "update-changelog": "rui-update-changelog-widget", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/web-actions/scripts/build.ts b/packages/modules/web-actions/scripts/build.mts similarity index 100% rename from packages/modules/web-actions/scripts/build.ts rename to packages/modules/web-actions/scripts/build.mts diff --git a/packages/modules/web-actions/scripts/push-update.ts b/packages/modules/web-actions/scripts/push-update.mts similarity index 100% rename from packages/modules/web-actions/scripts/push-update.ts rename to packages/modules/web-actions/scripts/push-update.mts diff --git a/packages/modules/web-actions/scripts/release.ts b/packages/modules/web-actions/scripts/release.mts similarity index 100% rename from packages/modules/web-actions/scripts/release.ts rename to packages/modules/web-actions/scripts/release.mts diff --git a/packages/pluggableWidgets/charts-web/package.json b/packages/pluggableWidgets/charts-web/package.json index 5491945e8f..df15b437c5 100644 --- a/packages/pluggableWidgets/charts-web/package.json +++ b/packages/pluggableWidgets/charts-web/package.json @@ -39,12 +39,12 @@ "branchName": "main" }, "scripts": { - "build": "ts-node --project scripts/tsconfig.json scripts/build.ts development", + "build": "node scripts/build.mts development", "create-gh-release": "rui-create-gh-release", "format": "prettier --ignore-path ./node_modules/@mendix/prettier-config-web-widgets/global-prettierignore --write .", "lint": "tsc --project scripts/tsconfig.json && eslint . package.json", "publish-marketplace": "rui-publish-marketplace", - "release": "ts-node --project scripts/tsconfig.json scripts/build.ts production", + "release": "node scripts/build.mts production", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/pluggableWidgets/charts-web/scripts/build.ts b/packages/pluggableWidgets/charts-web/scripts/build.mts similarity index 94% rename from packages/pluggableWidgets/charts-web/scripts/build.ts rename to packages/pluggableWidgets/charts-web/scripts/build.mts index 1bdfae3d85..64742ed7ab 100755 --- a/packages/pluggableWidgets/charts-web/scripts/build.ts +++ b/packages/pluggableWidgets/charts-web/scripts/build.mts @@ -1,7 +1,7 @@ -#!/usr/bin/env ts-node-script +#!/usr/bin/env node import { cp, mkdir, rm, unzip, zip } from "@mendix/automation-utils/shell"; -import { logStep, removeDist, runWidgetSteps, WidgetStepParams } from "@mendix/automation-utils/steps"; +import { logStep, removeDist, runWidgetSteps, type WidgetStepParams } from "@mendix/automation-utils/steps"; import { getWidgetInfo, listPackages } from "@mendix/automation-utils/utils"; import { dirname, join } from "node:path"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec9a750a46..74c47f85f6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -217,14 +217,11 @@ importers: specifier: ^5.4.1 version: 5.4.1 peggy: - specifier: ^1.2.0 - version: 1.2.0 + specifier: 5.1.0 + version: 5.1.0 shelljs: specifier: ^0.8.5 version: 0.8.5 - ts-node: - specifier: ^10.9.1 - version: 10.9.2(@swc/core@1.15.46)(@types/node@24.12.4)(typescript@5.9.3) zod: specifier: ^3.25.76 version: 3.25.76 @@ -4689,6 +4686,10 @@ packages: resolution: {integrity: sha512-7FNeNl8NCE7aINx7WXiKQrPYZWC/hvrTsmk6zmxbI7LTXE7hVek/n8AfVgpe2y82zl3w0HvCHN0bVKMBoJcC0w==} engines: {node: '>= 10.0.0'} + '@peggyjs/from-mem@3.1.3': + resolution: {integrity: sha512-LLlgtfXIaeYXoOYovOI0spLM8ZXaqkAlmcRRrLzHJzLMqkU6Sw0R4KMoCoHx1PjaP815pSCBlS+BN6aD8t1Jgg==} + engines: {node: '>=20.8'} + '@pkgjs/parseargs@0.11.0': resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -9477,9 +9478,9 @@ packages: resolution: {integrity: sha512-DlOzet0HO7OEnmUmB6wWGJrrdvbyJKftI1bhMitK7O2N8W2gc757yyYBbINy9IDafXAV9wmKr9t7xsTaNKRG5Q==} engines: {node: '>=20.16.0 || >=22.3.0'} - peggy@1.2.0: - resolution: {integrity: sha512-PQ+NKpAobImfMprYQtc4Egmyi29bidRGEX0kKjCU5uuW09s0Cthwqhfy7mLkwcB4VcgacE5L/ZjruD/kOPCUUw==} - engines: {node: '>=10'} + peggy@5.1.0: + resolution: {integrity: sha512-IEo5aYRZ2kXH4Qby06cjtL114PZnwLoTiA41vUmg2vPZgANn+c87m5BUurhuDr5/cu758ZlpgsAfBVx+hhO5+w==} + engines: {node: '>=20'} hasBin: true performance-now@2.1.0: @@ -10370,6 +10371,11 @@ packages: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true + semver@7.7.4: + resolution: {integrity: sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==} + engines: {node: '>=10'} + hasBin: true + semver@7.8.5: resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==} engines: {node: '>=10'} @@ -10510,6 +10516,10 @@ packages: engines: {node: '>=20'} hasBin: true + source-map-generator@2.0.6: + resolution: {integrity: sha512-IlassDs1Ve8nV6uyQZXF9kdkJpVKnMte2JZQXu13M0A5zwc+vu6+LNHfmxsHBMDtoZE21RHiKI0/xvpecZRCNg==} + engines: {node: '>=20'} + source-map-js@1.2.1: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} @@ -13268,6 +13278,10 @@ snapshots: '@parcel/watcher-win32-x64': 2.6.0 optional: true + '@peggyjs/from-mem@3.1.3': + dependencies: + semver: 7.7.4 + '@pkgjs/parseargs@0.11.0': optional: true @@ -18715,7 +18729,11 @@ snapshots: optionalDependencies: '@napi-rs/canvas': 0.1.100 - peggy@1.2.0: {} + peggy@5.1.0: + dependencies: + '@peggyjs/from-mem': 3.1.3 + commander: 14.0.3 + source-map-generator: 2.0.6 performance-now@2.1.0: {} @@ -20058,6 +20076,8 @@ snapshots: semver@6.3.1: {} + semver@7.7.4: {} + semver@7.8.5: {} send@1.2.1: @@ -20235,6 +20255,8 @@ snapshots: sort-object-keys: 2.1.0 tinyglobby: 0.2.17 + source-map-generator@2.0.6: {} + source-map-js@1.2.1: {} source-map-support@0.5.13: From a9fe1a8a69e44aa603a5b7305bcbfc3b27aba742 Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Wed, 21 Oct 2026 17:04:33 +0200 Subject: [PATCH 02/14] fix(data-widgets): fix rollup plugin typings under NodeNext in bundle-xlsx script --- .../modules/data-widgets/scripts/steps/bundle-xlsx.mts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/modules/data-widgets/scripts/steps/bundle-xlsx.mts b/packages/modules/data-widgets/scripts/steps/bundle-xlsx.mts index 78c087b49b..3d5d4fa425 100644 --- a/packages/modules/data-widgets/scripts/steps/bundle-xlsx.mts +++ b/packages/modules/data-widgets/scripts/steps/bundle-xlsx.mts @@ -1,10 +1,13 @@ import path from "node:path"; -import resolve from "@rollup/plugin-node-resolve"; -import terser from "@rollup/plugin-terser"; +import { nodeResolve } from "@rollup/plugin-node-resolve"; +import terserPlugin from "@rollup/plugin-terser"; import * as rollup from "rollup"; import type { InputOptions, OutputOptions } from "rollup"; import { copyActionsFiles, logStep, type ModuleStepParams } from "@mendix/automation-utils/steps"; +// The plugin's typings are resolved as CJS under NodeNext, but Node loads its ESM build whose default export is the function. +const terser = terserPlugin as unknown as typeof terserPlugin.default; + type Entry = { getInputOptions: (params: ModuleStepParams) => InputOptions; getOutputOptions: (params: ModuleStepParams) => OutputOptions; @@ -14,7 +17,7 @@ const xlsxExportTools: Entry = { getInputOptions: ({ config }) => ({ input: path.join(config.paths.javascriptsource, "actions/xlsx-export-tools.js"), plugins: [ - resolve(), + nodeResolve(), terser({ module: true, ecma: 2017 From 0a93c47959cc1c31dcd7818dc0273b5d8f95c422 Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Wed, 21 Oct 2026 17:09:51 +0200 Subject: [PATCH 03/14] chore(automation-utils): commit generated changelog parsers instead of compiling on prepare --- .gitignore | 3 - .prettierignore | 3 +- automation/utils/package.json | 7 +- .../changelog-parser/parser/module/module.mjs | 1349 +++++++++++++++++ .../changelog-parser/parser/widget/widget.mjs | 1134 ++++++++++++++ 5 files changed, 2489 insertions(+), 7 deletions(-) create mode 100644 automation/utils/src/changelog-parser/parser/module/module.mjs create mode 100644 automation/utils/src/changelog-parser/parser/widget/widget.mjs diff --git a/.gitignore b/.gitignore index 9d28ee849f..507c9780d9 100644 --- a/.gitignore +++ b/.gitignore @@ -20,9 +20,6 @@ mendixProject **/pluggableWidgets/**/artifacts **/gh-*/release-notes.txt -**/automation/utils/**/parser/module/module.mjs -**/automation/utils/**/parser/widget/widget.mjs - tests .turbo *.tsbuildinfo diff --git a/.prettierignore b/.prettierignore index 269a46be8d..510072c4f5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -9,4 +9,5 @@ packages/modules/*/src/javascriptsource/**/*.js .idea .husky .vscode -pnpm-lock.yaml \ No newline at end of file +pnpm-lock.yaml +automation/utils/src/changelog-parser/parser/*/*.mjs diff --git a/automation/utils/package.json b/automation/utils/package.json index 87d41475f8..d0505dea2c 100644 --- a/automation/utils/package.json +++ b/automation/utils/package.json @@ -40,14 +40,15 @@ "scripts": { "changelog": "node bin/rui-changelog-helper.ts", "check-changelogs": "node bin/rui-check-changelogs.ts", - "compile:parser:module": "peggy --format es -o ./src/changelog-parser/parser/widget/widget.mjs ./src/changelog-parser/parser/widget/widget.pegjs", - "compile:parser:widget": "peggy --format es -o ./src/changelog-parser/parser/module/module.mjs ./src/changelog-parser/parser/module/module.pegjs", + "compile:parser": "pnpm run compile:parser:module && pnpm run compile:parser:widget", + "compile:parser:module": "peggy --format es -o ./src/changelog-parser/parser/module/module.mjs ./src/changelog-parser/parser/module/module.pegjs", + "compile:parser:widget": "peggy --format es -o ./src/changelog-parser/parser/widget/widget.mjs ./src/changelog-parser/parser/widget/widget.pegjs", "format": "prettier --write .", "include-oss-in-artifact": "node bin/rui-include-oss-in-artifact.ts", "lint": "eslint --ext .jsx,.js,.ts,.tsx src/", "merge-changelogs-pr": "node bin/rui-merge-changelogs-pr.ts", "oss-clearance": "node bin/rui-oss-clearance.ts", - "prepare": "pnpm run compile:parser:widget && pnpm run compile:parser:module && tsc", + "prepare": "tsc", "prepare-release": "node bin/rui-prepare-release.ts", "start": "tsc --watch" }, diff --git a/automation/utils/src/changelog-parser/parser/module/module.mjs b/automation/utils/src/changelog-parser/parser/module/module.mjs new file mode 100644 index 0000000000..91eb377346 --- /dev/null +++ b/automation/utils/src/changelog-parser/parser/module/module.mjs @@ -0,0 +1,1349 @@ +// Generated by Peggy 1.2.0. +// +// https://peggyjs.org/ + +function peg$subclass(child, parent) { + function C() { this.constructor = child; } + C.prototype = parent.prototype; + child.prototype = new C(); +} + +function peg$SyntaxError(message, expected, found, location) { + var self = Error.call(this, message); + if (Object.setPrototypeOf) { + Object.setPrototypeOf(self, peg$SyntaxError.prototype); + } + self.expected = expected; + self.found = found; + self.location = location; + self.name = "SyntaxError"; + return self; +} + +peg$subclass(peg$SyntaxError, Error); + +function peg$padEnd(str, targetLength, padString) { + padString = padString || " "; + if (str.length > targetLength) { return str; } + targetLength -= str.length; + padString += padString.repeat(targetLength); + return str + padString.slice(0, targetLength); +} + +peg$SyntaxError.prototype.format = function(sources) { + var str = "Error: " + this.message; + if (this.location) { + var src = null; + var k; + for (k = 0; k < sources.length; k++) { + if (sources[k].source === this.location.source) { + src = sources[k].text.split(/\r\n|\n|\r/g); + break; + } + } + var s = this.location.start; + var loc = this.location.source + ":" + s.line + ":" + s.column; + if (src) { + var e = this.location.end; + var filler = peg$padEnd("", s.line.toString().length); + var line = src[s.line - 1]; + var last = s.line === e.line ? e.column : line.length + 1; + str += "\n --> " + loc + "\n" + + filler + " |\n" + + s.line + " | " + line + "\n" + + filler + " | " + peg$padEnd("", s.column - 1) + + peg$padEnd("", last - s.column, "^"); + } else { + str += "\n at " + loc; + } + } + return str; +}; + +peg$SyntaxError.buildMessage = function(expected, found) { + var DESCRIBE_EXPECTATION_FNS = { + literal: function(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, + + class: function(expectation) { + var escapedParts = expectation.parts.map(function(part) { + return Array.isArray(part) + ? classEscape(part[0]) + "-" + classEscape(part[1]) + : classEscape(part); + }); + + return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; + }, + + any: function() { + return "any character"; + }, + + end: function() { + return "end of input"; + }, + + other: function(expectation) { + return expectation.description; + } + }; + + function hex(ch) { + return ch.charCodeAt(0).toString(16).toUpperCase(); + } + + function literalEscape(s) { + return s + .replace(/\\/g, "\\\\") + .replace(/"/g, "\\\"") + .replace(/\0/g, "\\0") + .replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); + } + + function classEscape(s) { + return s + .replace(/\\/g, "\\\\") + .replace(/\]/g, "\\]") + .replace(/\^/g, "\\^") + .replace(/-/g, "\\-") + .replace(/\0/g, "\\0") + .replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); + } + + function describeExpectation(expectation) { + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } + + function describeExpected(expected) { + var descriptions = expected.map(describeExpectation); + var i, j; + + descriptions.sort(); + + if (descriptions.length > 0) { + for (i = 1, j = 1; i < descriptions.length; i++) { + if (descriptions[i - 1] !== descriptions[i]) { + descriptions[j] = descriptions[i]; + j++; + } + } + descriptions.length = j; + } + + switch (descriptions.length) { + case 1: + return descriptions[0]; + + case 2: + return descriptions[0] + " or " + descriptions[1]; + + default: + return descriptions.slice(0, -1).join(", ") + + ", or " + + descriptions[descriptions.length - 1]; + } + } + + function describeFound(found) { + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } + + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; +}; + +function peg$parse(input, options) { + options = options !== undefined ? options : {}; + + var peg$FAILED = {}; + var peg$source = options.grammarSource; + + var peg$startRuleFunctions = { ChangelogFile: peg$parseChangelogFile }; + var peg$startRuleFunction = peg$parseChangelogFile; + + var peg$c0 = "##"; + var peg$c1 = "["; + var peg$c2 = "]"; + var peg$c3 = "-"; + var peg$c4 = "[Unreleased]"; + var peg$c5 = "###"; + var peg$c6 = "####"; + var peg$c7 = "# Changelog"; + var peg$c8 = "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)."; + var peg$c9 = "Added"; + var peg$c10 = "Changed"; + var peg$c11 = "Deprecated"; + var peg$c12 = "Removed"; + var peg$c13 = "Fixed"; + var peg$c14 = "Security"; + var peg$c15 = "Breaking changes"; + var peg$c16 = "Documentation"; + var peg$c17 = "."; + + var peg$r0 = /^[^\-]/; + var peg$r1 = /^[\n\r]/; + var peg$r2 = /^[^\n\r]/; + var peg$r3 = /^[^\r\n]/; + var peg$r4 = /^[0-9]/; + var peg$r5 = /^[ \t\n\r]/; + + var peg$e0 = peg$literalExpectation("##", false); + var peg$e1 = peg$literalExpectation("[", false); + var peg$e2 = peg$literalExpectation("]", false); + var peg$e3 = peg$classExpectation(["-"], true, false); + var peg$e4 = peg$literalExpectation("-", false); + var peg$e5 = peg$classExpectation(["\n", "\r"], false, false); + var peg$e6 = peg$literalExpectation("[Unreleased]", false); + var peg$e7 = peg$literalExpectation("###", false); + var peg$e8 = peg$classExpectation(["\n", "\r"], true, false); + var peg$e9 = peg$literalExpectation("####", false); + var peg$e10 = peg$literalExpectation("# Changelog", false); + var peg$e11 = peg$literalExpectation("The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).", false); + var peg$e12 = peg$literalExpectation("Added", false); + var peg$e13 = peg$literalExpectation("Changed", false); + var peg$e14 = peg$literalExpectation("Deprecated", false); + var peg$e15 = peg$literalExpectation("Removed", false); + var peg$e16 = peg$literalExpectation("Fixed", false); + var peg$e17 = peg$literalExpectation("Security", false); + var peg$e18 = peg$literalExpectation("Breaking changes", false); + var peg$e19 = peg$literalExpectation("Documentation", false); + var peg$e20 = peg$literalExpectation(".", false); + var peg$e21 = peg$classExpectation(["\r", "\n"], true, false); + var peg$e22 = peg$classExpectation([["0", "9"]], false, false); + var peg$e23 = peg$otherExpectation("whitespace"); + var peg$e24 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false); + + var peg$f0 = function(header, content) { return { header, content, moduleName: options.moduleName } }; + var peg$f1 = function(header, sections, subcomponents) { return { ...header, sections,subcomponents } }; + var peg$f2 = function(version, name, date) { return { type: "normal", version, date, name: name.join("").trim() }}; + var peg$f3 = function() { return { type: "unreleased" }}; + var peg$f4 = function(title, txt) { return { type: "note", title, text: txt }}; + var peg$f5 = function(type, logs) { return { type, logs } }; + var peg$f6 = function(head, sections) { return { ...head, sections } }; + var peg$f7 = function(version, name) { return { version, name: name.join("") }}; + var peg$f8 = function(name) { return { name: name.join("") }}; + var peg$f9 = function(log) { return log.join("") }; + var peg$f10 = function(txt) { return txt; }; + var peg$f11 = function() { return text().trim() }; + var peg$f12 = function() { return text() }; + var peg$f13 = function(major, minor, patch) { return options.Version.fromParts(major, minor, patch) }; + var peg$f14 = function(year, month, day) { return new Date(year, month - 1, day) }; + var peg$f15 = function(txt) { return txt.join("").trim() }; + var peg$f16 = function() { return parseInt(text(), 10) }; + + var peg$currPos = 0; + var peg$savedPos = 0; + var peg$posDetailsCache = [{ line: 1, column: 1 }]; + var peg$maxFailPos = 0; + var peg$maxFailExpected = []; + var peg$silentFails = 0; + + var peg$result; + + if ("startRule" in options) { + if (!(options.startRule in peg$startRuleFunctions)) { + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + } + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + + function text() { + return input.substring(peg$savedPos, peg$currPos); + } + + function offset() { + return peg$savedPos; + } + + function range() { + return { + source: peg$source, + start: peg$savedPos, + end: peg$currPos + }; + } + + function location() { + return peg$computeLocation(peg$savedPos, peg$currPos); + } + + function expected(description, location) { + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); + + throw peg$buildStructuredError( + [peg$otherExpectation(description)], + input.substring(peg$savedPos, peg$currPos), + location + ); + } + + function error(message, location) { + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); + + throw peg$buildSimpleError(message, location); + } + + function peg$literalExpectation(text, ignoreCase) { + return { type: "literal", text: text, ignoreCase: ignoreCase }; + } + + function peg$classExpectation(parts, inverted, ignoreCase) { + return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + } + + function peg$anyExpectation() { + return { type: "any" }; + } + + function peg$endExpectation() { + return { type: "end" }; + } + + function peg$otherExpectation(description) { + return { type: "other", description: description }; + } + + function peg$computePosDetails(pos) { + var details = peg$posDetailsCache[pos]; + var p; + + if (details) { + return details; + } else { + p = pos - 1; + while (!peg$posDetailsCache[p]) { + p--; + } + + details = peg$posDetailsCache[p]; + details = { + line: details.line, + column: details.column + }; + + while (p < pos) { + if (input.charCodeAt(p) === 10) { + details.line++; + details.column = 1; + } else { + details.column++; + } + + p++; + } + + peg$posDetailsCache[pos] = details; + + return details; + } + } + + function peg$computeLocation(startPos, endPos) { + var startPosDetails = peg$computePosDetails(startPos); + var endPosDetails = peg$computePosDetails(endPos); + + return { + source: peg$source, + start: { + offset: startPos, + line: startPosDetails.line, + column: startPosDetails.column + }, + end: { + offset: endPos, + line: endPosDetails.line, + column: endPosDetails.column + } + }; + } + + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { return; } + + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; + } + + peg$maxFailExpected.push(expected); + } + + function peg$buildSimpleError(message, location) { + return new peg$SyntaxError(message, null, null, location); + } + + function peg$buildStructuredError(expected, found, location) { + return new peg$SyntaxError( + peg$SyntaxError.buildMessage(expected, found), + expected, + found, + location + ); + } + + function peg$parseChangelogFile() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parseChangelogHead(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + s3 = []; + s4 = peg$parseModuleVersionEntry(); + if (s4 === peg$FAILED) { + s4 = peg$parseOtherNotes(); + } + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parseModuleVersionEntry(); + if (s4 === peg$FAILED) { + s4 = peg$parseOtherNotes(); + } + } + } else { + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f0(s1, s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseModuleVersionEntry() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = peg$parseVersionHeader(); + if (s1 === peg$FAILED) { + s1 = peg$parseUnreleasedVersionHeader(); + } + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + s3 = []; + s4 = peg$parseWidgetSection(); + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parseWidgetSection(); + } + s4 = peg$parse_(); + s5 = []; + s6 = peg$parseSubWidgetEntry(); + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$parseSubWidgetEntry(); + } + s6 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f1(s1, s3, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseVersionHeader() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c0) { + s1 = peg$c0; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (input.charCodeAt(peg$currPos) === 91) { + s3 = peg$c1; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parseSemVer(); + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 93) { + s5 = peg$c2; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parse_(); + s7 = []; + if (peg$r0.test(input.charAt(peg$currPos))) { + s8 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + while (s8 !== peg$FAILED) { + s7.push(s8); + if (peg$r0.test(input.charAt(peg$currPos))) { + s8 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + } + s8 = peg$parse_(); + if (input.charCodeAt(peg$currPos) === 45) { + s9 = peg$c3; + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + if (s9 !== peg$FAILED) { + s10 = peg$parse_(); + s11 = peg$parseDate(); + if (s11 !== peg$FAILED) { + s12 = []; + if (peg$r1.test(input.charAt(peg$currPos))) { + s13 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s13 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } + while (s13 !== peg$FAILED) { + s12.push(s13); + if (peg$r1.test(input.charAt(peg$currPos))) { + s13 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s13 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } + } + peg$savedPos = s0; + s0 = peg$f2(s4, s7, s11); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseUnreleasedVersionHeader() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c0) { + s1 = peg$c0; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (input.substr(peg$currPos, 12) === peg$c4) { + s3 = peg$c4; + peg$currPos += 12; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f3(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseOtherNotes() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c0) { + s1 = peg$c0; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + s3 = peg$parseOneLineSentence(); + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + s5 = peg$parseOneLineSentence(); + if (s5 !== peg$FAILED) { + s6 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f4(s3, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseWidgetSection() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.substr(peg$currPos, 3) === peg$c5) { + s2 = peg$c5; + peg$currPos += 3; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + s4 = peg$parseSectionType(); + if (s4 !== peg$FAILED) { + s5 = peg$parse_(); + s6 = []; + s7 = peg$parseLogLine(); + if (s7 !== peg$FAILED) { + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parseLogLine(); + } + } else { + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f5(s4, s6); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseSubWidgetEntry() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseSubComponentEntryHeaderWithVersion(); + if (s1 === peg$FAILED) { + s1 = peg$parseSubComponentEntryHeaderWithoutVersion(); + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseSubComponentSection(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseSubComponentSection(); + } + peg$savedPos = s0; + s0 = peg$f6(s1, s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseSubComponentEntryHeaderWithVersion() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.substr(peg$currPos, 3) === peg$c5) { + s2 = peg$c5; + peg$currPos += 3; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + if (input.charCodeAt(peg$currPos) === 91) { + s4 = peg$c1; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseSemVer(); + if (s5 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 93) { + s6 = peg$c2; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } + if (s6 !== peg$FAILED) { + s7 = peg$parse_(); + s8 = []; + if (peg$r2.test(input.charAt(peg$currPos))) { + s9 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + if (s9 !== peg$FAILED) { + while (s9 !== peg$FAILED) { + s8.push(s9); + if (peg$r2.test(input.charAt(peg$currPos))) { + s9 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + } + } else { + s8 = peg$FAILED; + } + if (s8 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f7(s5, s8); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseSubComponentEntryHeaderWithoutVersion() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.substr(peg$currPos, 3) === peg$c5) { + s2 = peg$c5; + peg$currPos += 3; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + s4 = []; + if (peg$r2.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + if (s5 !== peg$FAILED) { + while (s5 !== peg$FAILED) { + s4.push(s5); + if (peg$r2.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + } + } else { + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f8(s4); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseSubComponentSection() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.substr(peg$currPos, 4) === peg$c6) { + s2 = peg$c6; + peg$currPos += 4; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e9); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + s4 = peg$parseSectionType(); + if (s4 !== peg$FAILED) { + s5 = peg$parse_(); + s6 = []; + s7 = peg$parseLogLine(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parseLogLine(); + } + peg$savedPos = s0; + s0 = peg$f5(s4, s6); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseLogLine() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.charCodeAt(peg$currPos) === 45) { + s2 = peg$c3; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + s4 = []; + if (peg$r2.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + if (s5 !== peg$FAILED) { + while (s5 !== peg$FAILED) { + s4.push(s5); + if (peg$r2.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + } + } else { + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + s5 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f9(s4); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseChangelogHead() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseChangelogHeadLine1(); + if (s1 !== peg$FAILED) { + s2 = peg$parseChangelogHeadLine2(); + if (s2 !== peg$FAILED) { + s3 = peg$parseChangelogHeadLine3(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f10(s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseChangelogHeadLine1() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.substr(peg$currPos, 11) === peg$c7) { + s2 = peg$c7; + peg$currPos += 11; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseChangelogHeadLine2() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parse_(); + s2 = peg$parseOneLineSentence(); + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f11(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseChangelogHeadLine3() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.substr(peg$currPos, 168) === peg$c8) { + s2 = peg$c8; + peg$currPos += 168; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseSectionType() { + var s0, s1; + + if (input.substr(peg$currPos, 5) === peg$c9) { + s0 = peg$c9; + peg$currPos += 5; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 7) === peg$c10) { + s0 = peg$c10; + peg$currPos += 7; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e13); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 10) === peg$c11) { + s0 = peg$c11; + peg$currPos += 10; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e14); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 7) === peg$c12) { + s0 = peg$c12; + peg$currPos += 7; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 5) === peg$c13) { + s0 = peg$c13; + peg$currPos += 5; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 8) === peg$c14) { + s0 = peg$c14; + peg$currPos += 8; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 16) === peg$c15) { + s0 = peg$c15; + peg$currPos += 16; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 13) === peg$c16) { + s1 = peg$c16; + peg$currPos += 13; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e19); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f12(); + } + s0 = s1; + } + } + } + } + } + } + } + + return s0; + } + + function peg$parseSemVer() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = peg$parseNumber(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s2 = peg$c17; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseNumber(); + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c17; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseNumber(); + if (s5 !== peg$FAILED) { + s6 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f13(s1, s3, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDate() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseNumber(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s2 = peg$c3; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseNumber(); + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s4 = peg$c3; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseNumber(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f14(s1, s3, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseOneLineSentence() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + if (peg$r3.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$r3.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f15(s1); + } + s0 = s1; + + return s0; + } + + function peg$parseNumber() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + if (peg$r4.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e22); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$r4.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e22); } + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f16(); + } + s0 = s1; + + return s0; + } + + function peg$parse_() { + var s0, s1; + + peg$silentFails++; + s0 = []; + if (peg$r5.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + while (s1 !== peg$FAILED) { + s0.push(s1); + if (peg$r5.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e24); } + } + } + peg$silentFails--; + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e23); } + + return s0; + } + + peg$result = peg$startRuleFunction(); + + if (peg$result !== peg$FAILED && peg$currPos === input.length) { + return peg$result; + } else { + if (peg$result !== peg$FAILED && peg$currPos < input.length) { + peg$fail(peg$endExpectation()); + } + + throw peg$buildStructuredError( + peg$maxFailExpected, + peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, + peg$maxFailPos < input.length + ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) + : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) + ); + } +} + +export { + peg$SyntaxError as SyntaxError, + peg$parse as parse +}; diff --git a/automation/utils/src/changelog-parser/parser/widget/widget.mjs b/automation/utils/src/changelog-parser/parser/widget/widget.mjs new file mode 100644 index 0000000000..6a193a2bd5 --- /dev/null +++ b/automation/utils/src/changelog-parser/parser/widget/widget.mjs @@ -0,0 +1,1134 @@ +// Generated by Peggy 1.2.0. +// +// https://peggyjs.org/ + +function peg$subclass(child, parent) { + function C() { this.constructor = child; } + C.prototype = parent.prototype; + child.prototype = new C(); +} + +function peg$SyntaxError(message, expected, found, location) { + var self = Error.call(this, message); + if (Object.setPrototypeOf) { + Object.setPrototypeOf(self, peg$SyntaxError.prototype); + } + self.expected = expected; + self.found = found; + self.location = location; + self.name = "SyntaxError"; + return self; +} + +peg$subclass(peg$SyntaxError, Error); + +function peg$padEnd(str, targetLength, padString) { + padString = padString || " "; + if (str.length > targetLength) { return str; } + targetLength -= str.length; + padString += padString.repeat(targetLength); + return str + padString.slice(0, targetLength); +} + +peg$SyntaxError.prototype.format = function(sources) { + var str = "Error: " + this.message; + if (this.location) { + var src = null; + var k; + for (k = 0; k < sources.length; k++) { + if (sources[k].source === this.location.source) { + src = sources[k].text.split(/\r\n|\n|\r/g); + break; + } + } + var s = this.location.start; + var loc = this.location.source + ":" + s.line + ":" + s.column; + if (src) { + var e = this.location.end; + var filler = peg$padEnd("", s.line.toString().length); + var line = src[s.line - 1]; + var last = s.line === e.line ? e.column : line.length + 1; + str += "\n --> " + loc + "\n" + + filler + " |\n" + + s.line + " | " + line + "\n" + + filler + " | " + peg$padEnd("", s.column - 1) + + peg$padEnd("", last - s.column, "^"); + } else { + str += "\n at " + loc; + } + } + return str; +}; + +peg$SyntaxError.buildMessage = function(expected, found) { + var DESCRIBE_EXPECTATION_FNS = { + literal: function(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, + + class: function(expectation) { + var escapedParts = expectation.parts.map(function(part) { + return Array.isArray(part) + ? classEscape(part[0]) + "-" + classEscape(part[1]) + : classEscape(part); + }); + + return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; + }, + + any: function() { + return "any character"; + }, + + end: function() { + return "end of input"; + }, + + other: function(expectation) { + return expectation.description; + } + }; + + function hex(ch) { + return ch.charCodeAt(0).toString(16).toUpperCase(); + } + + function literalEscape(s) { + return s + .replace(/\\/g, "\\\\") + .replace(/"/g, "\\\"") + .replace(/\0/g, "\\0") + .replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); + } + + function classEscape(s) { + return s + .replace(/\\/g, "\\\\") + .replace(/\]/g, "\\]") + .replace(/\^/g, "\\^") + .replace(/-/g, "\\-") + .replace(/\0/g, "\\0") + .replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); + } + + function describeExpectation(expectation) { + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } + + function describeExpected(expected) { + var descriptions = expected.map(describeExpectation); + var i, j; + + descriptions.sort(); + + if (descriptions.length > 0) { + for (i = 1, j = 1; i < descriptions.length; i++) { + if (descriptions[i - 1] !== descriptions[i]) { + descriptions[j] = descriptions[i]; + j++; + } + } + descriptions.length = j; + } + + switch (descriptions.length) { + case 1: + return descriptions[0]; + + case 2: + return descriptions[0] + " or " + descriptions[1]; + + default: + return descriptions.slice(0, -1).join(", ") + + ", or " + + descriptions[descriptions.length - 1]; + } + } + + function describeFound(found) { + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } + + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; +}; + +function peg$parse(input, options) { + options = options !== undefined ? options : {}; + + var peg$FAILED = {}; + var peg$source = options.grammarSource; + + var peg$startRuleFunctions = { ChangelogFile: peg$parseChangelogFile }; + var peg$startRuleFunction = peg$parseChangelogFile; + + var peg$c0 = "##"; + var peg$c1 = "["; + var peg$c2 = "]"; + var peg$c3 = "-"; + var peg$c4 = "[Unreleased]"; + var peg$c5 = "Older releases"; + var peg$c6 = "###"; + var peg$c7 = "# Changelog"; + var peg$c8 = "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)."; + var peg$c9 = "Added"; + var peg$c10 = "Changed"; + var peg$c11 = "Deprecated"; + var peg$c12 = "Removed"; + var peg$c13 = "Fixed"; + var peg$c14 = "Security"; + var peg$c15 = "Breaking changes"; + var peg$c16 = "Documentation"; + var peg$c17 = "."; + + var peg$r0 = /^[^\r\n]/; + var peg$r1 = /^[0-9]/; + var peg$r2 = /^[ \t\n\r]/; + + var peg$e0 = peg$literalExpectation("##", false); + var peg$e1 = peg$literalExpectation("[", false); + var peg$e2 = peg$literalExpectation("]", false); + var peg$e3 = peg$literalExpectation("-", false); + var peg$e4 = peg$literalExpectation("[Unreleased]", false); + var peg$e5 = peg$literalExpectation("Older releases", false); + var peg$e6 = peg$literalExpectation("###", false); + var peg$e7 = peg$literalExpectation("# Changelog", false); + var peg$e8 = peg$literalExpectation("The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).", false); + var peg$e9 = peg$literalExpectation("Added", false); + var peg$e10 = peg$literalExpectation("Changed", false); + var peg$e11 = peg$literalExpectation("Deprecated", false); + var peg$e12 = peg$literalExpectation("Removed", false); + var peg$e13 = peg$literalExpectation("Fixed", false); + var peg$e14 = peg$literalExpectation("Security", false); + var peg$e15 = peg$literalExpectation("Breaking changes", false); + var peg$e16 = peg$literalExpectation("Documentation", false); + var peg$e17 = peg$literalExpectation(".", false); + var peg$e18 = peg$classExpectation(["\r", "\n"], true, false); + var peg$e19 = peg$classExpectation([["0", "9"]], false, false); + var peg$e20 = peg$otherExpectation("whitespace"); + var peg$e21 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false); + + var peg$f0 = function(header, content) { return { header, content } }; + var peg$f1 = function(header, sections) { return { ...header, sections } }; + var peg$f2 = function(version, date) { return { type: "normal", version, date }}; + var peg$f3 = function() { return { type: "unreleased" }}; + var peg$f4 = function(title, txt) { return { type: "note", title, text: txt }}; + var peg$f5 = function(type, logs) { return { type, logs } }; + var peg$f6 = function(log) { return log }; + var peg$f7 = function(txt) { return txt; }; + var peg$f8 = function() { return text().trim() }; + var peg$f9 = function() { return text() }; + var peg$f10 = function(major, minor, patch) { return options.Version.fromParts(major, minor, patch) }; + var peg$f11 = function(year, month, day) { return new Date(year, month - 1, day) }; + var peg$f12 = function(txt) { return txt.join("").trim() }; + var peg$f13 = function() { return parseInt(text(), 10) }; + + var peg$currPos = 0; + var peg$savedPos = 0; + var peg$posDetailsCache = [{ line: 1, column: 1 }]; + var peg$maxFailPos = 0; + var peg$maxFailExpected = []; + var peg$silentFails = 0; + + var peg$result; + + if ("startRule" in options) { + if (!(options.startRule in peg$startRuleFunctions)) { + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + } + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + + function text() { + return input.substring(peg$savedPos, peg$currPos); + } + + function offset() { + return peg$savedPos; + } + + function range() { + return { + source: peg$source, + start: peg$savedPos, + end: peg$currPos + }; + } + + function location() { + return peg$computeLocation(peg$savedPos, peg$currPos); + } + + function expected(description, location) { + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); + + throw peg$buildStructuredError( + [peg$otherExpectation(description)], + input.substring(peg$savedPos, peg$currPos), + location + ); + } + + function error(message, location) { + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); + + throw peg$buildSimpleError(message, location); + } + + function peg$literalExpectation(text, ignoreCase) { + return { type: "literal", text: text, ignoreCase: ignoreCase }; + } + + function peg$classExpectation(parts, inverted, ignoreCase) { + return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + } + + function peg$anyExpectation() { + return { type: "any" }; + } + + function peg$endExpectation() { + return { type: "end" }; + } + + function peg$otherExpectation(description) { + return { type: "other", description: description }; + } + + function peg$computePosDetails(pos) { + var details = peg$posDetailsCache[pos]; + var p; + + if (details) { + return details; + } else { + p = pos - 1; + while (!peg$posDetailsCache[p]) { + p--; + } + + details = peg$posDetailsCache[p]; + details = { + line: details.line, + column: details.column + }; + + while (p < pos) { + if (input.charCodeAt(p) === 10) { + details.line++; + details.column = 1; + } else { + details.column++; + } + + p++; + } + + peg$posDetailsCache[pos] = details; + + return details; + } + } + + function peg$computeLocation(startPos, endPos) { + var startPosDetails = peg$computePosDetails(startPos); + var endPosDetails = peg$computePosDetails(endPos); + + return { + source: peg$source, + start: { + offset: startPos, + line: startPosDetails.line, + column: startPosDetails.column + }, + end: { + offset: endPos, + line: endPosDetails.line, + column: endPosDetails.column + } + }; + } + + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { return; } + + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; + } + + peg$maxFailExpected.push(expected); + } + + function peg$buildSimpleError(message, location) { + return new peg$SyntaxError(message, null, null, location); + } + + function peg$buildStructuredError(expected, found, location) { + return new peg$SyntaxError( + peg$SyntaxError.buildMessage(expected, found), + expected, + found, + location + ); + } + + function peg$parseChangelogFile() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parseChangelogHead(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + s3 = []; + s4 = peg$parseUnreleasedVersionEntry(); + if (s4 === peg$FAILED) { + s4 = peg$parseReleasedVersionEntry(); + if (s4 === peg$FAILED) { + s4 = peg$parseOtherNotes(); + } + } + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parseUnreleasedVersionEntry(); + if (s4 === peg$FAILED) { + s4 = peg$parseReleasedVersionEntry(); + if (s4 === peg$FAILED) { + s4 = peg$parseOtherNotes(); + } + } + } + } else { + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f0(s1, s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseUnreleasedVersionEntry() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parseUnreleasedVersionHeader(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + s3 = []; + s4 = peg$parseWidgetSection(); + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parseWidgetSection(); + } + s4 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f1(s1, s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseReleasedVersionEntry() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parseVersionHeader(); + if (s1 === peg$FAILED) { + s1 = peg$parseUnreleasedVersionHeader(); + } + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + s3 = []; + s4 = peg$parseWidgetSection(); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parseWidgetSection(); + } + } else { + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f1(s1, s3); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseVersionHeader() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c0) { + s1 = peg$c0; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (input.charCodeAt(peg$currPos) === 91) { + s3 = peg$c1; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parseSemVer(); + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 93) { + s5 = peg$c2; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parse_(); + if (input.charCodeAt(peg$currPos) === 45) { + s7 = peg$c3; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + if (s7 !== peg$FAILED) { + s8 = peg$parse_(); + s9 = peg$parseDate(); + if (s9 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f2(s4, s9); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseUnreleasedVersionHeader() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c0) { + s1 = peg$c0; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (input.substr(peg$currPos, 12) === peg$c4) { + s3 = peg$c4; + peg$currPos += 12; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f3(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseOtherNotes() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c0) { + s1 = peg$c0; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (input.substr(peg$currPos, 14) === peg$c5) { + s3 = peg$c5; + peg$currPos += 14; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + s5 = []; + s6 = peg$parseOneLineSentence(); + if (s6 !== peg$FAILED) { + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$parseOneLineSentence(); + } + } else { + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + s6 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f4(s3, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseWidgetSection() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.substr(peg$currPos, 3) === peg$c6) { + s2 = peg$c6; + peg$currPos += 3; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + s4 = peg$parseSectionType(); + if (s4 !== peg$FAILED) { + s5 = peg$parse_(); + s6 = []; + s7 = peg$parseLogLine(); + if (s7 !== peg$FAILED) { + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parseLogLine(); + } + } else { + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f5(s4, s6); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseLogLine() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.charCodeAt(peg$currPos) === 45) { + s2 = peg$c3; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + s4 = peg$parseOneLineSentence(); + if (s4 !== peg$FAILED) { + s5 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f6(s4); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseChangelogHead() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseChangelogHeadLine1(); + if (s1 !== peg$FAILED) { + s2 = peg$parseChangelogHeadLine2(); + if (s2 !== peg$FAILED) { + s3 = peg$parseChangelogHeadLine3(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f7(s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseChangelogHeadLine1() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.substr(peg$currPos, 11) === peg$c7) { + s2 = peg$c7; + peg$currPos += 11; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e7); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseChangelogHeadLine2() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parse_(); + s2 = peg$parseOneLineSentence(); + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f8(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseChangelogHeadLine3() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (input.substr(peg$currPos, 168) === peg$c8) { + s2 = peg$c8; + peg$currPos += 168; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e8); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseSectionType() { + var s0, s1; + + if (input.substr(peg$currPos, 5) === peg$c9) { + s0 = peg$c9; + peg$currPos += 5; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e9); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 7) === peg$c10) { + s0 = peg$c10; + peg$currPos += 7; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 10) === peg$c11) { + s0 = peg$c11; + peg$currPos += 10; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e11); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 7) === peg$c12) { + s0 = peg$c12; + peg$currPos += 7; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e12); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 5) === peg$c13) { + s0 = peg$c13; + peg$currPos += 5; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e13); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 8) === peg$c14) { + s0 = peg$c14; + peg$currPos += 8; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e14); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 16) === peg$c15) { + s0 = peg$c15; + peg$currPos += 16; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e15); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 13) === peg$c16) { + s1 = peg$c16; + peg$currPos += 13; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e16); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f9(); + } + s0 = s1; + } + } + } + } + } + } + } + + return s0; + } + + function peg$parseSemVer() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = peg$parseNumber(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s2 = peg$c17; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseNumber(); + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c17; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e17); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseNumber(); + if (s5 !== peg$FAILED) { + s6 = peg$parse_(); + peg$savedPos = s0; + s0 = peg$f10(s1, s3, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseDate() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseNumber(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s2 = peg$c3; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseNumber(); + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s4 = peg$c3; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseNumber(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f11(s1, s3, s5); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseOneLineSentence() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + if (peg$r0.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$r0.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e18); } + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f12(s1); + } + s0 = s1; + + return s0; + } + + function peg$parseNumber() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + if (peg$r1.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e19); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$r1.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e19); } + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f13(); + } + s0 = s1; + + return s0; + } + + function peg$parse_() { + var s0, s1; + + peg$silentFails++; + s0 = []; + if (peg$r2.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + while (s1 !== peg$FAILED) { + s0.push(s1); + if (peg$r2.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e21); } + } + } + peg$silentFails--; + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e20); } + + return s0; + } + + peg$result = peg$startRuleFunction(); + + if (peg$result !== peg$FAILED && peg$currPos === input.length) { + return peg$result; + } else { + if (peg$result !== peg$FAILED && peg$currPos < input.length) { + peg$fail(peg$endExpectation()); + } + + throw peg$buildStructuredError( + peg$maxFailExpected, + peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, + peg$maxFailPos < input.length + ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) + : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) + ); + } +} + +export { + peg$SyntaxError as SyntaxError, + peg$parse as parse +}; From 8f2884c94674ddb2a4bf8260260a0c0db2a15557 Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Wed, 21 Oct 2026 17:11:30 +0200 Subject: [PATCH 04/14] chore: type-check package scripts in lint for all modules --- packages/modules/calendar/package.json | 1 + packages/modules/calendar/scripts/tsconfig.json | 3 ++- packages/modules/file-uploader/package.json | 1 + packages/modules/file-uploader/scripts/tsconfig.json | 3 ++- packages/modules/google-tag/package.json | 1 + packages/modules/google-tag/scripts/tsconfig.json | 3 ++- packages/modules/pusher/package.json | 1 + packages/modules/web-actions/package.json | 2 +- packages/modules/web-actions/scripts/tsconfig.json | 3 ++- 9 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/modules/calendar/package.json b/packages/modules/calendar/package.json index 44b6264740..643122ccaf 100644 --- a/packages/modules/calendar/package.json +++ b/packages/modules/calendar/package.json @@ -30,6 +30,7 @@ "scripts": { "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", + "lint": "tsc --project scripts/tsconfig.json", "publish-marketplace": "rui-publish-marketplace", "push-update": "node scripts/push-update.mts", "release:module": "node scripts/release.mts", diff --git a/packages/modules/calendar/scripts/tsconfig.json b/packages/modules/calendar/scripts/tsconfig.json index eeb4a6cc48..65920b4c2a 100644 --- a/packages/modules/calendar/scripts/tsconfig.json +++ b/packages/modules/calendar/scripts/tsconfig.json @@ -1,3 +1,4 @@ { - "extends": "@mendix/automation-utils/tsconfig" + "extends": "@mendix/automation-utils/tsconfig", + "include": ["."] } diff --git a/packages/modules/file-uploader/package.json b/packages/modules/file-uploader/package.json index 6298268715..a58c21e4eb 100644 --- a/packages/modules/file-uploader/package.json +++ b/packages/modules/file-uploader/package.json @@ -30,6 +30,7 @@ "scripts": { "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", + "lint": "tsc --project scripts/tsconfig.json", "publish-marketplace": "rui-publish-marketplace", "push-update": "node scripts/push-update.mts", "release:module": "node scripts/release.mts", diff --git a/packages/modules/file-uploader/scripts/tsconfig.json b/packages/modules/file-uploader/scripts/tsconfig.json index eeb4a6cc48..65920b4c2a 100644 --- a/packages/modules/file-uploader/scripts/tsconfig.json +++ b/packages/modules/file-uploader/scripts/tsconfig.json @@ -1,3 +1,4 @@ { - "extends": "@mendix/automation-utils/tsconfig" + "extends": "@mendix/automation-utils/tsconfig", + "include": ["."] } diff --git a/packages/modules/google-tag/package.json b/packages/modules/google-tag/package.json index f3a4645ac7..5cf4f12680 100644 --- a/packages/modules/google-tag/package.json +++ b/packages/modules/google-tag/package.json @@ -30,6 +30,7 @@ "scripts": { "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", + "lint": "tsc --project scripts/tsconfig.json", "publish-marketplace": "rui-publish-marketplace", "push-update": "node scripts/push-update.mts", "release:module": "node scripts/release.mts", diff --git a/packages/modules/google-tag/scripts/tsconfig.json b/packages/modules/google-tag/scripts/tsconfig.json index eeb4a6cc48..65920b4c2a 100644 --- a/packages/modules/google-tag/scripts/tsconfig.json +++ b/packages/modules/google-tag/scripts/tsconfig.json @@ -1,3 +1,4 @@ { - "extends": "@mendix/automation-utils/tsconfig" + "extends": "@mendix/automation-utils/tsconfig", + "include": ["."] } diff --git a/packages/modules/pusher/package.json b/packages/modules/pusher/package.json index 4b52839f9a..9954f80d2f 100644 --- a/packages/modules/pusher/package.json +++ b/packages/modules/pusher/package.json @@ -31,6 +31,7 @@ "scripts": { "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", + "lint": "tsc --project scripts/tsconfig.json", "publish-marketplace": "rui-publish-marketplace", "push-update": "node scripts/push-update.mts", "release:module": "node scripts/release.mts", diff --git a/packages/modules/web-actions/package.json b/packages/modules/web-actions/package.json index 6d35f61f02..d3f02d3472 100644 --- a/packages/modules/web-actions/package.json +++ b/packages/modules/web-actions/package.json @@ -27,7 +27,7 @@ "build:module": "node scripts/build.mts", "create-gh-release": "rui-create-gh-release", "format": "echo 'Skip as actions use special format'", - "lint": "eslint --ext .js src/", + "lint": "tsc --project scripts/tsconfig.json && eslint --ext .js src/", "publish-marketplace": "rui-publish-marketplace", "push-update": "node scripts/push-update.mts", "release:module": "node scripts/release.mts", diff --git a/packages/modules/web-actions/scripts/tsconfig.json b/packages/modules/web-actions/scripts/tsconfig.json index eeb4a6cc48..65920b4c2a 100644 --- a/packages/modules/web-actions/scripts/tsconfig.json +++ b/packages/modules/web-actions/scripts/tsconfig.json @@ -1,3 +1,4 @@ { - "extends": "@mendix/automation-utils/tsconfig" + "extends": "@mendix/automation-utils/tsconfig", + "include": ["."] } From e9c7f301931aea3ae6533ed8accb5f23f72598aa Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Wed, 21 Oct 2026 17:11:52 +0200 Subject: [PATCH 05/14] docs: describe scripts type-check setup for modules --- docs/requirements/widget-to-module.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/requirements/widget-to-module.md b/docs/requirements/widget-to-module.md index 178ad0ca96..7edc8c0a11 100644 --- a/docs/requirements/widget-to-module.md +++ b/docs/requirements/widget-to-module.md @@ -60,9 +60,9 @@ packages/modules/calendar/ ├─ LICENSE ← Apache 2.0 copy ├─ .prettierrc.js └─ scripts/ - ├─ build.ts - ├─ push-update.ts - ├─ release.ts + ├─ build.mts + ├─ push-update.mts + ├─ release.mts └─ tsconfig.json ``` @@ -84,6 +84,7 @@ packages/modules/calendar/ }, "scripts": { "build:module": "node scripts/build.mts", + "lint": "tsc --project scripts/tsconfig.json", "release:module": "node scripts/release.mts" } } @@ -91,6 +92,15 @@ packages/modules/calendar/ Scripts are copied from `packages/modules/file-uploader/scripts/`. +Node runs the scripts with native type stripping, which does not type-check them, so `lint` runs `tsc` on them instead. `scripts/tsconfig.json` must declare its own `include`, because an inherited `include` resolves relative to `automation/utils`: + +```json +{ + "extends": "@mendix/automation-utils/tsconfig", + "include": ["."] +} +``` + --- ## 6. Local Verification From 9310f68632560b77af452d88c3a867a1453b0b3c Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Wed, 21 Oct 2026 17:28:05 +0200 Subject: [PATCH 06/14] chore: make modules ESM packages and use .ts for their scripts --- docs/requirements/widget-to-module.md | 15 ++++++++------- .../calendar/{.prettierrc.js => .prettierrc.cjs} | 0 packages/modules/calendar/package.json | 7 ++++--- .../calendar/scripts/{build.mts => build.ts} | 0 .../scripts/{push-update.mts => push-update.ts} | 0 .../calendar/scripts/{release.mts => release.ts} | 0 .../{.prettierrc.js => .prettierrc.cjs} | 0 packages/modules/data-widgets/package.json | 9 +++++---- .../data-widgets/scripts/{build.mts => build.ts} | 2 +- .../scripts/{push-update.mts => push-update.ts} | 0 .../scripts/{release.mts => release.ts} | 2 +- .../data-widgets/scripts/{start.mts => start.ts} | 0 .../steps/{bundle-xlsx.mts => bundle-xlsx.ts} | 0 .../{.prettierrc.js => .prettierrc.cjs} | 0 packages/modules/file-uploader/package.json | 7 ++++--- .../file-uploader/scripts/{build.mts => build.ts} | 0 .../scripts/{push-update.mts => push-update.ts} | 0 .../scripts/{release.mts => release.ts} | 0 .../{.prettierrc.js => .prettierrc.cjs} | 0 packages/modules/google-tag/package.json | 7 ++++--- .../google-tag/scripts/{build.mts => build.ts} | 0 .../scripts/{push-update.mts => push-update.ts} | 0 .../scripts/{release.mts => release.ts} | 0 .../pusher/{.prettierrc.js => .prettierrc.cjs} | 0 packages/modules/pusher/package.json | 7 ++++--- .../pusher/scripts/{build.mts => build.ts} | 0 .../scripts/{push-update.mts => push-update.ts} | 0 .../pusher/scripts/{release.mts => release.ts} | 0 .../{.prettierrc.js => .prettierrc.cjs} | 0 packages/modules/web-actions/package.json | 7 ++++--- .../web-actions/scripts/{build.mts => build.ts} | 0 .../scripts/{push-update.mts => push-update.ts} | 0 .../scripts/{release.mts => release.ts} | 0 33 files changed, 35 insertions(+), 28 deletions(-) rename packages/modules/calendar/{.prettierrc.js => .prettierrc.cjs} (100%) rename packages/modules/calendar/scripts/{build.mts => build.ts} (100%) rename packages/modules/calendar/scripts/{push-update.mts => push-update.ts} (100%) rename packages/modules/calendar/scripts/{release.mts => release.ts} (100%) rename packages/modules/data-widgets/{.prettierrc.js => .prettierrc.cjs} (100%) rename packages/modules/data-widgets/scripts/{build.mts => build.ts} (92%) rename packages/modules/data-widgets/scripts/{push-update.mts => push-update.ts} (100%) rename packages/modules/data-widgets/scripts/{release.mts => release.ts} (94%) rename packages/modules/data-widgets/scripts/{start.mts => start.ts} (100%) rename packages/modules/data-widgets/scripts/steps/{bundle-xlsx.mts => bundle-xlsx.ts} (100%) rename packages/modules/file-uploader/{.prettierrc.js => .prettierrc.cjs} (100%) rename packages/modules/file-uploader/scripts/{build.mts => build.ts} (100%) rename packages/modules/file-uploader/scripts/{push-update.mts => push-update.ts} (100%) rename packages/modules/file-uploader/scripts/{release.mts => release.ts} (100%) rename packages/modules/google-tag/{.prettierrc.js => .prettierrc.cjs} (100%) rename packages/modules/google-tag/scripts/{build.mts => build.ts} (100%) rename packages/modules/google-tag/scripts/{push-update.mts => push-update.ts} (100%) rename packages/modules/google-tag/scripts/{release.mts => release.ts} (100%) rename packages/modules/pusher/{.prettierrc.js => .prettierrc.cjs} (100%) rename packages/modules/pusher/scripts/{build.mts => build.ts} (100%) rename packages/modules/pusher/scripts/{push-update.mts => push-update.ts} (100%) rename packages/modules/pusher/scripts/{release.mts => release.ts} (100%) rename packages/modules/web-actions/{.prettierrc.js => .prettierrc.cjs} (100%) rename packages/modules/web-actions/scripts/{build.mts => build.ts} (100%) rename packages/modules/web-actions/scripts/{push-update.mts => push-update.ts} (100%) rename packages/modules/web-actions/scripts/{release.mts => release.ts} (100%) diff --git a/docs/requirements/widget-to-module.md b/docs/requirements/widget-to-module.md index 7edc8c0a11..2b7ddc48d6 100644 --- a/docs/requirements/widget-to-module.md +++ b/docs/requirements/widget-to-module.md @@ -58,11 +58,11 @@ packages/modules/calendar/ ├─ package.json ← see template below ├─ CHANGELOG.md ├─ LICENSE ← Apache 2.0 copy - ├─ .prettierrc.js + ├─ .prettierrc.cjs └─ scripts/ - ├─ build.mts - ├─ push-update.mts - ├─ release.mts + ├─ build.ts + ├─ push-update.ts + ├─ release.ts └─ tsconfig.json ``` @@ -82,15 +82,16 @@ packages/modules/calendar/ "githubUrl": "https://github.com/mendix/testProjects", "branchName": "calendar-web" }, + "type": "module", "scripts": { - "build:module": "node scripts/build.mts", + "build:module": "node scripts/build.ts", "lint": "tsc --project scripts/tsconfig.json", - "release:module": "node scripts/release.mts" + "release:module": "node scripts/release.ts" } } ``` -Scripts are copied from `packages/modules/file-uploader/scripts/`. +Scripts are copied from `packages/modules/file-uploader/scripts/`. `"type": "module"` lets Node run the `.ts` scripts as ESM; `mxpackage.type` is a separate, Mendix-specific field. Node runs the scripts with native type stripping, which does not type-check them, so `lint` runs `tsc` on them instead. `scripts/tsconfig.json` must declare its own `include`, because an inherited `include` resolves relative to `automation/utils`: diff --git a/packages/modules/calendar/.prettierrc.js b/packages/modules/calendar/.prettierrc.cjs similarity index 100% rename from packages/modules/calendar/.prettierrc.js rename to packages/modules/calendar/.prettierrc.cjs diff --git a/packages/modules/calendar/package.json b/packages/modules/calendar/package.json index 643122ccaf..04ec5fd18f 100644 --- a/packages/modules/calendar/package.json +++ b/packages/modules/calendar/package.json @@ -27,13 +27,14 @@ "githubUrl": "https://github.com/mendix/testProjects", "branchName": "calendar-web" }, + "type": "module", "scripts": { - "build:module": "node scripts/build.mts", + "build:module": "node scripts/build.ts", "create-gh-release": "rui-create-gh-release", "lint": "tsc --project scripts/tsconfig.json", "publish-marketplace": "rui-publish-marketplace", - "push-update": "node scripts/push-update.mts", - "release:module": "node scripts/release.mts", + "push-update": "node scripts/push-update.ts", + "release:module": "node scripts/release.ts", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/calendar/scripts/build.mts b/packages/modules/calendar/scripts/build.ts similarity index 100% rename from packages/modules/calendar/scripts/build.mts rename to packages/modules/calendar/scripts/build.ts diff --git a/packages/modules/calendar/scripts/push-update.mts b/packages/modules/calendar/scripts/push-update.ts similarity index 100% rename from packages/modules/calendar/scripts/push-update.mts rename to packages/modules/calendar/scripts/push-update.ts diff --git a/packages/modules/calendar/scripts/release.mts b/packages/modules/calendar/scripts/release.ts similarity index 100% rename from packages/modules/calendar/scripts/release.mts rename to packages/modules/calendar/scripts/release.ts diff --git a/packages/modules/data-widgets/.prettierrc.js b/packages/modules/data-widgets/.prettierrc.cjs similarity index 100% rename from packages/modules/data-widgets/.prettierrc.js rename to packages/modules/data-widgets/.prettierrc.cjs diff --git a/packages/modules/data-widgets/package.json b/packages/modules/data-widgets/package.json index 4f9e17c1e4..1893db819b 100644 --- a/packages/modules/data-widgets/package.json +++ b/packages/modules/data-widgets/package.json @@ -36,18 +36,19 @@ "githubUrl": "https://github.com/mendix/DataWidgets-module", "branchName": "main" }, + "type": "module", "scripts": { "build:deps": "turbo run build --filter=@mendix/data-widgets^...", "build:include-deps": "pnpm run build:deps && pnpm run build:module", - "build:module": "node scripts/build.mts", + "build:module": "node scripts/build.ts", "create-gh-release": "rui-create-gh-release", "create-module-mpk": "turbo release:module --filter @mendix/data-widgets", "format": "prettier --ignore-path ./node_modules/@mendix/prettier-config-web-widgets/global-prettierignore --write .", "lint": "tsc --project scripts/tsconfig.json && eslint . package.json", "publish-marketplace": "rui-publish-marketplace", - "push-update": "node scripts/push-update.mts", - "release:module": "node scripts/release.mts", - "start": "node scripts/start.mts", + "push-update": "node scripts/push-update.ts", + "release:module": "node scripts/release.ts", + "start": "node scripts/start.ts", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/data-widgets/scripts/build.mts b/packages/modules/data-widgets/scripts/build.ts similarity index 92% rename from packages/modules/data-widgets/scripts/build.mts rename to packages/modules/data-widgets/scripts/build.ts index 6a6a6b4a5e..3e0e3a4144 100755 --- a/packages/modules/data-widgets/scripts/build.mts +++ b/packages/modules/data-widgets/scripts/build.ts @@ -9,7 +9,7 @@ import { writeModuleVersion } from "@mendix/automation-utils/steps"; -import { bundleXLSX } from "./steps/bundle-xlsx.mts"; +import { bundleXLSX } from "./steps/bundle-xlsx.ts"; async function main(): Promise { await runModuleSteps({ diff --git a/packages/modules/data-widgets/scripts/push-update.mts b/packages/modules/data-widgets/scripts/push-update.ts similarity index 100% rename from packages/modules/data-widgets/scripts/push-update.mts rename to packages/modules/data-widgets/scripts/push-update.ts diff --git a/packages/modules/data-widgets/scripts/release.mts b/packages/modules/data-widgets/scripts/release.ts similarity index 94% rename from packages/modules/data-widgets/scripts/release.mts rename to packages/modules/data-widgets/scripts/release.ts index ea305c703a..1f1ae73835 100755 --- a/packages/modules/data-widgets/scripts/release.mts +++ b/packages/modules/data-widgets/scripts/release.ts @@ -14,7 +14,7 @@ import { writeModuleVersion } from "@mendix/automation-utils/steps"; -import { bundleXLSX } from "./steps/bundle-xlsx.mts"; +import { bundleXLSX } from "./steps/bundle-xlsx.ts"; async function main(): Promise { await runModuleSteps({ diff --git a/packages/modules/data-widgets/scripts/start.mts b/packages/modules/data-widgets/scripts/start.ts similarity index 100% rename from packages/modules/data-widgets/scripts/start.mts rename to packages/modules/data-widgets/scripts/start.ts diff --git a/packages/modules/data-widgets/scripts/steps/bundle-xlsx.mts b/packages/modules/data-widgets/scripts/steps/bundle-xlsx.ts similarity index 100% rename from packages/modules/data-widgets/scripts/steps/bundle-xlsx.mts rename to packages/modules/data-widgets/scripts/steps/bundle-xlsx.ts diff --git a/packages/modules/file-uploader/.prettierrc.js b/packages/modules/file-uploader/.prettierrc.cjs similarity index 100% rename from packages/modules/file-uploader/.prettierrc.js rename to packages/modules/file-uploader/.prettierrc.cjs diff --git a/packages/modules/file-uploader/package.json b/packages/modules/file-uploader/package.json index a58c21e4eb..1dd4e8cbe8 100644 --- a/packages/modules/file-uploader/package.json +++ b/packages/modules/file-uploader/package.json @@ -27,13 +27,14 @@ "githubUrl": "https://github.com/mendix/testProjects", "branchName": "fileuploader-web" }, + "type": "module", "scripts": { - "build:module": "node scripts/build.mts", + "build:module": "node scripts/build.ts", "create-gh-release": "rui-create-gh-release", "lint": "tsc --project scripts/tsconfig.json", "publish-marketplace": "rui-publish-marketplace", - "push-update": "node scripts/push-update.mts", - "release:module": "node scripts/release.mts", + "push-update": "node scripts/push-update.ts", + "release:module": "node scripts/release.ts", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/file-uploader/scripts/build.mts b/packages/modules/file-uploader/scripts/build.ts similarity index 100% rename from packages/modules/file-uploader/scripts/build.mts rename to packages/modules/file-uploader/scripts/build.ts diff --git a/packages/modules/file-uploader/scripts/push-update.mts b/packages/modules/file-uploader/scripts/push-update.ts similarity index 100% rename from packages/modules/file-uploader/scripts/push-update.mts rename to packages/modules/file-uploader/scripts/push-update.ts diff --git a/packages/modules/file-uploader/scripts/release.mts b/packages/modules/file-uploader/scripts/release.ts similarity index 100% rename from packages/modules/file-uploader/scripts/release.mts rename to packages/modules/file-uploader/scripts/release.ts diff --git a/packages/modules/google-tag/.prettierrc.js b/packages/modules/google-tag/.prettierrc.cjs similarity index 100% rename from packages/modules/google-tag/.prettierrc.js rename to packages/modules/google-tag/.prettierrc.cjs diff --git a/packages/modules/google-tag/package.json b/packages/modules/google-tag/package.json index 5cf4f12680..b4fed78f68 100644 --- a/packages/modules/google-tag/package.json +++ b/packages/modules/google-tag/package.json @@ -27,13 +27,14 @@ "githubUrl": "https://github.com/mendix/testProjects", "branchName": "google-tag-web" }, + "type": "module", "scripts": { - "build:module": "node scripts/build.mts", + "build:module": "node scripts/build.ts", "create-gh-release": "rui-create-gh-release", "lint": "tsc --project scripts/tsconfig.json", "publish-marketplace": "rui-publish-marketplace", - "push-update": "node scripts/push-update.mts", - "release:module": "node scripts/release.mts", + "push-update": "node scripts/push-update.ts", + "release:module": "node scripts/release.ts", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/google-tag/scripts/build.mts b/packages/modules/google-tag/scripts/build.ts similarity index 100% rename from packages/modules/google-tag/scripts/build.mts rename to packages/modules/google-tag/scripts/build.ts diff --git a/packages/modules/google-tag/scripts/push-update.mts b/packages/modules/google-tag/scripts/push-update.ts similarity index 100% rename from packages/modules/google-tag/scripts/push-update.mts rename to packages/modules/google-tag/scripts/push-update.ts diff --git a/packages/modules/google-tag/scripts/release.mts b/packages/modules/google-tag/scripts/release.ts similarity index 100% rename from packages/modules/google-tag/scripts/release.mts rename to packages/modules/google-tag/scripts/release.ts diff --git a/packages/modules/pusher/.prettierrc.js b/packages/modules/pusher/.prettierrc.cjs similarity index 100% rename from packages/modules/pusher/.prettierrc.js rename to packages/modules/pusher/.prettierrc.cjs diff --git a/packages/modules/pusher/package.json b/packages/modules/pusher/package.json index 9954f80d2f..e98a4a2385 100644 --- a/packages/modules/pusher/package.json +++ b/packages/modules/pusher/package.json @@ -28,13 +28,14 @@ "githubUrl": "https://github.com/mendix/testProjects", "branchName": "pusher-web" }, + "type": "module", "scripts": { - "build:module": "node scripts/build.mts", + "build:module": "node scripts/build.ts", "create-gh-release": "rui-create-gh-release", "lint": "tsc --project scripts/tsconfig.json", "publish-marketplace": "rui-publish-marketplace", - "push-update": "node scripts/push-update.mts", - "release:module": "node scripts/release.mts", + "push-update": "node scripts/push-update.ts", + "release:module": "node scripts/release.ts", "update-changelog": "rui-update-changelog-module", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/pusher/scripts/build.mts b/packages/modules/pusher/scripts/build.ts similarity index 100% rename from packages/modules/pusher/scripts/build.mts rename to packages/modules/pusher/scripts/build.ts diff --git a/packages/modules/pusher/scripts/push-update.mts b/packages/modules/pusher/scripts/push-update.ts similarity index 100% rename from packages/modules/pusher/scripts/push-update.mts rename to packages/modules/pusher/scripts/push-update.ts diff --git a/packages/modules/pusher/scripts/release.mts b/packages/modules/pusher/scripts/release.ts similarity index 100% rename from packages/modules/pusher/scripts/release.mts rename to packages/modules/pusher/scripts/release.ts diff --git a/packages/modules/web-actions/.prettierrc.js b/packages/modules/web-actions/.prettierrc.cjs similarity index 100% rename from packages/modules/web-actions/.prettierrc.js rename to packages/modules/web-actions/.prettierrc.cjs diff --git a/packages/modules/web-actions/package.json b/packages/modules/web-actions/package.json index d3f02d3472..37e8611c1a 100644 --- a/packages/modules/web-actions/package.json +++ b/packages/modules/web-actions/package.json @@ -23,14 +23,15 @@ "githubUrl": "https://github.com/mendix/Web-Actions", "branchName": "main" }, + "type": "module", "scripts": { - "build:module": "node scripts/build.mts", + "build:module": "node scripts/build.ts", "create-gh-release": "rui-create-gh-release", "format": "echo 'Skip as actions use special format'", "lint": "tsc --project scripts/tsconfig.json && eslint --ext .js src/", "publish-marketplace": "rui-publish-marketplace", - "push-update": "node scripts/push-update.mts", - "release:module": "node scripts/release.mts", + "push-update": "node scripts/push-update.ts", + "release:module": "node scripts/release.ts", "update-changelog": "rui-update-changelog-widget", "verify": "rui-verify-package-format" }, diff --git a/packages/modules/web-actions/scripts/build.mts b/packages/modules/web-actions/scripts/build.ts similarity index 100% rename from packages/modules/web-actions/scripts/build.mts rename to packages/modules/web-actions/scripts/build.ts diff --git a/packages/modules/web-actions/scripts/push-update.mts b/packages/modules/web-actions/scripts/push-update.ts similarity index 100% rename from packages/modules/web-actions/scripts/push-update.mts rename to packages/modules/web-actions/scripts/push-update.ts diff --git a/packages/modules/web-actions/scripts/release.mts b/packages/modules/web-actions/scripts/release.ts similarity index 100% rename from packages/modules/web-actions/scripts/release.mts rename to packages/modules/web-actions/scripts/release.ts From bfbe9149c11639d442398f4962b716ad740082c5 Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Wed, 21 Oct 2026 17:35:57 +0200 Subject: [PATCH 07/14] chore(automation-utils): regenerate changelog parsers with peggy 5.1.0 --- .../changelog-parser/parser/module/module.mjs | 637 +++++++++--------- .../changelog-parser/parser/widget/widget.mjs | 581 ++++++++-------- 2 files changed, 636 insertions(+), 582 deletions(-) diff --git a/automation/utils/src/changelog-parser/parser/module/module.mjs b/automation/utils/src/changelog-parser/parser/module/module.mjs index 91eb377346..82fb43ecb8 100644 --- a/automation/utils/src/changelog-parser/parser/module/module.mjs +++ b/automation/utils/src/changelog-parser/parser/module/module.mjs @@ -1,254 +1,248 @@ -// Generated by Peggy 1.2.0. +// @generated by Peggy 5.1.0. // // https://peggyjs.org/ -function peg$subclass(child, parent) { - function C() { this.constructor = child; } - C.prototype = parent.prototype; - child.prototype = new C(); -} -function peg$SyntaxError(message, expected, found, location) { - var self = Error.call(this, message); - if (Object.setPrototypeOf) { - Object.setPrototypeOf(self, peg$SyntaxError.prototype); +class peg$SyntaxError extends SyntaxError { + constructor(message, expected, found, location) { + super(message); + this.expected = expected; + this.found = found; + this.location = location; + this.name = "SyntaxError"; } - self.expected = expected; - self.found = found; - self.location = location; - self.name = "SyntaxError"; - return self; -} - -peg$subclass(peg$SyntaxError, Error); - -function peg$padEnd(str, targetLength, padString) { - padString = padString || " "; - if (str.length > targetLength) { return str; } - targetLength -= str.length; - padString += padString.repeat(targetLength); - return str + padString.slice(0, targetLength); -} -peg$SyntaxError.prototype.format = function(sources) { - var str = "Error: " + this.message; - if (this.location) { - var src = null; - var k; - for (k = 0; k < sources.length; k++) { - if (sources[k].source === this.location.source) { - src = sources[k].text.split(/\r\n|\n|\r/g); - break; + format(sources) { + let str = "Error: " + this.message; + if (this.location) { + let src = null; + const st = sources.find(s => s.source === this.location.source); + if (st) { + src = st.text.split(/\r\n|\n|\r/g); + } + const s = this.location.start; + const offset_s = (this.location.source && (typeof this.location.source.offset === "function")) + ? this.location.source.offset(s) + : s; + const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; + if (src) { + const e = this.location.end; + const filler = "".padEnd(offset_s.line.toString().length, " "); + const line = src[s.line - 1]; + const last = s.line === e.line ? e.column : line.length + 1; + const hatLen = (last - s.column) || 1; + str += "\n --> " + loc + "\n" + + filler + " |\n" + + offset_s.line + " | " + line + "\n" + + filler + " | " + "".padEnd(s.column - 1, " ") + + "".padEnd(hatLen, "^"); + } else { + str += "\n at " + loc; } } - var s = this.location.start; - var loc = this.location.source + ":" + s.line + ":" + s.column; - if (src) { - var e = this.location.end; - var filler = peg$padEnd("", s.line.toString().length); - var line = src[s.line - 1]; - var last = s.line === e.line ? e.column : line.length + 1; - str += "\n --> " + loc + "\n" - + filler + " |\n" - + s.line + " | " + line + "\n" - + filler + " | " + peg$padEnd("", s.column - 1) - + peg$padEnd("", last - s.column, "^"); - } else { - str += "\n at " + loc; - } + return str; } - return str; -}; -peg$SyntaxError.buildMessage = function(expected, found) { - var DESCRIBE_EXPECTATION_FNS = { - literal: function(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; - }, + static buildMessage(expected, found) { + function hex(ch) { + return ch.codePointAt(0).toString(16).toUpperCase(); + } - class: function(expectation) { - var escapedParts = expectation.parts.map(function(part) { - return Array.isArray(part) - ? classEscape(part[0]) + "-" + classEscape(part[1]) - : classEscape(part); - }); + const nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, "unicode") + ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu") + : null; + function unicodeEscape(s) { + if (nonPrintable) { + return s.replace(nonPrintable, ch => "\\u{" + hex(ch) + "}"); + } + return s; + } - return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; - }, + function literalEscape(s) { + return unicodeEscape(s + .replace(/\\/g, "\\\\") + .replace(/"/g, "\\\"") + .replace(/\0/g, "\\0") + .replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch)) + .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch))); + } - any: function() { - return "any character"; - }, + function classEscape(s) { + return unicodeEscape(s + .replace(/\\/g, "\\\\") + .replace(/\]/g, "\\]") + .replace(/\^/g, "\\^") + .replace(/-/g, "\\-") + .replace(/\0/g, "\\0") + .replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch)) + .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch))); + } - end: function() { - return "end of input"; - }, + const DESCRIBE_EXPECTATION_FNS = { + literal(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, - other: function(expectation) { - return expectation.description; - } - }; + class(expectation) { + const escapedParts = expectation.parts.map( + part => (Array.isArray(part) + ? classEscape(part[0]) + "-" + classEscape(part[1]) + : classEscape(part)) + ); - function hex(ch) { - return ch.charCodeAt(0).toString(16).toUpperCase(); - } + return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]" + (expectation.unicode ? "u" : ""); + }, - function literalEscape(s) { - return s - .replace(/\\/g, "\\\\") - .replace(/"/g, "\\\"") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); - } + any() { + return "any character"; + }, - function classEscape(s) { - return s - .replace(/\\/g, "\\\\") - .replace(/\]/g, "\\]") - .replace(/\^/g, "\\^") - .replace(/-/g, "\\-") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); - } + end() { + return "end of input"; + }, - function describeExpectation(expectation) { - return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); - } + other(expectation) { + return expectation.description; + }, + }; - function describeExpected(expected) { - var descriptions = expected.map(describeExpectation); - var i, j; + function describeExpectation(expectation) { + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } - descriptions.sort(); + function describeExpected(expected) { + const descriptions = expected.map(describeExpectation); + descriptions.sort(); - if (descriptions.length > 0) { - for (i = 1, j = 1; i < descriptions.length; i++) { - if (descriptions[i - 1] !== descriptions[i]) { - descriptions[j] = descriptions[i]; - j++; + if (descriptions.length > 0) { + let j = 1; + for (let i = 1; i < descriptions.length; i++) { + if (descriptions[i - 1] !== descriptions[i]) { + descriptions[j] = descriptions[i]; + j++; + } } + descriptions.length = j; } - descriptions.length = j; - } - switch (descriptions.length) { - case 1: - return descriptions[0]; + switch (descriptions.length) { + case 1: + return descriptions[0]; - case 2: - return descriptions[0] + " or " + descriptions[1]; + case 2: + return descriptions[0] + " or " + descriptions[1]; - default: - return descriptions.slice(0, -1).join(", ") - + ", or " - + descriptions[descriptions.length - 1]; + default: + return descriptions.slice(0, -1).join(", ") + + ", or " + + descriptions[descriptions.length - 1]; + } } - } - function describeFound(found) { - return found ? "\"" + literalEscape(found) + "\"" : "end of input"; - } + function describeFound(found) { + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } - return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; -}; + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; + } +} function peg$parse(input, options) { options = options !== undefined ? options : {}; - var peg$FAILED = {}; - var peg$source = options.grammarSource; - - var peg$startRuleFunctions = { ChangelogFile: peg$parseChangelogFile }; - var peg$startRuleFunction = peg$parseChangelogFile; - - var peg$c0 = "##"; - var peg$c1 = "["; - var peg$c2 = "]"; - var peg$c3 = "-"; - var peg$c4 = "[Unreleased]"; - var peg$c5 = "###"; - var peg$c6 = "####"; - var peg$c7 = "# Changelog"; - var peg$c8 = "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)."; - var peg$c9 = "Added"; - var peg$c10 = "Changed"; - var peg$c11 = "Deprecated"; - var peg$c12 = "Removed"; - var peg$c13 = "Fixed"; - var peg$c14 = "Security"; - var peg$c15 = "Breaking changes"; - var peg$c16 = "Documentation"; - var peg$c17 = "."; - - var peg$r0 = /^[^\-]/; - var peg$r1 = /^[\n\r]/; - var peg$r2 = /^[^\n\r]/; - var peg$r3 = /^[^\r\n]/; - var peg$r4 = /^[0-9]/; - var peg$r5 = /^[ \t\n\r]/; - - var peg$e0 = peg$literalExpectation("##", false); - var peg$e1 = peg$literalExpectation("[", false); - var peg$e2 = peg$literalExpectation("]", false); - var peg$e3 = peg$classExpectation(["-"], true, false); - var peg$e4 = peg$literalExpectation("-", false); - var peg$e5 = peg$classExpectation(["\n", "\r"], false, false); - var peg$e6 = peg$literalExpectation("[Unreleased]", false); - var peg$e7 = peg$literalExpectation("###", false); - var peg$e8 = peg$classExpectation(["\n", "\r"], true, false); - var peg$e9 = peg$literalExpectation("####", false); - var peg$e10 = peg$literalExpectation("# Changelog", false); - var peg$e11 = peg$literalExpectation("The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).", false); - var peg$e12 = peg$literalExpectation("Added", false); - var peg$e13 = peg$literalExpectation("Changed", false); - var peg$e14 = peg$literalExpectation("Deprecated", false); - var peg$e15 = peg$literalExpectation("Removed", false); - var peg$e16 = peg$literalExpectation("Fixed", false); - var peg$e17 = peg$literalExpectation("Security", false); - var peg$e18 = peg$literalExpectation("Breaking changes", false); - var peg$e19 = peg$literalExpectation("Documentation", false); - var peg$e20 = peg$literalExpectation(".", false); - var peg$e21 = peg$classExpectation(["\r", "\n"], true, false); - var peg$e22 = peg$classExpectation([["0", "9"]], false, false); - var peg$e23 = peg$otherExpectation("whitespace"); - var peg$e24 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false); - - var peg$f0 = function(header, content) { return { header, content, moduleName: options.moduleName } }; - var peg$f1 = function(header, sections, subcomponents) { return { ...header, sections,subcomponents } }; - var peg$f2 = function(version, name, date) { return { type: "normal", version, date, name: name.join("").trim() }}; - var peg$f3 = function() { return { type: "unreleased" }}; - var peg$f4 = function(title, txt) { return { type: "note", title, text: txt }}; - var peg$f5 = function(type, logs) { return { type, logs } }; - var peg$f6 = function(head, sections) { return { ...head, sections } }; - var peg$f7 = function(version, name) { return { version, name: name.join("") }}; - var peg$f8 = function(name) { return { name: name.join("") }}; - var peg$f9 = function(log) { return log.join("") }; - var peg$f10 = function(txt) { return txt; }; - var peg$f11 = function() { return text().trim() }; - var peg$f12 = function() { return text() }; - var peg$f13 = function(major, minor, patch) { return options.Version.fromParts(major, minor, patch) }; - var peg$f14 = function(year, month, day) { return new Date(year, month - 1, day) }; - var peg$f15 = function(txt) { return txt.join("").trim() }; - var peg$f16 = function() { return parseInt(text(), 10) }; - - var peg$currPos = 0; - var peg$savedPos = 0; - var peg$posDetailsCache = [{ line: 1, column: 1 }]; - var peg$maxFailPos = 0; - var peg$maxFailExpected = []; - var peg$silentFails = 0; - - var peg$result; - - if ("startRule" in options) { + const peg$FAILED = {}; + const peg$source = options.grammarSource; + + const peg$startRuleFunctions = { + ChangelogFile: peg$parseChangelogFile, + }; + let peg$startRuleFunction = peg$parseChangelogFile; + + const peg$c0 = "##"; + const peg$c1 = "["; + const peg$c2 = "]"; + const peg$c3 = "-"; + const peg$c4 = "[Unreleased]"; + const peg$c5 = "###"; + const peg$c6 = "####"; + const peg$c7 = "# Changelog"; + const peg$c8 = "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)."; + const peg$c9 = "Added"; + const peg$c10 = "Changed"; + const peg$c11 = "Deprecated"; + const peg$c12 = "Removed"; + const peg$c13 = "Fixed"; + const peg$c14 = "Security"; + const peg$c15 = "Breaking changes"; + const peg$c16 = "Documentation"; + const peg$c17 = "."; + + const peg$r0 = /^[^\-]/; + const peg$r1 = /^[\n\r]/; + const peg$r2 = /^[^\n\r]/; + const peg$r3 = /^[^\r\n]/; + const peg$r4 = /^[0-9]/; + const peg$r5 = /^[ \t\n\r]/; + + const peg$e0 = peg$literalExpectation("##", false); + const peg$e1 = peg$literalExpectation("[", false); + const peg$e2 = peg$literalExpectation("]", false); + const peg$e3 = peg$classExpectation(["-"], true, false, false); + const peg$e4 = peg$literalExpectation("-", false); + const peg$e5 = peg$classExpectation(["\n", "\r"], false, false, false); + const peg$e6 = peg$literalExpectation("[Unreleased]", false); + const peg$e7 = peg$literalExpectation("###", false); + const peg$e8 = peg$classExpectation(["\n", "\r"], true, false, false); + const peg$e9 = peg$literalExpectation("####", false); + const peg$e10 = peg$literalExpectation("# Changelog", false); + const peg$e11 = peg$literalExpectation("The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).", false); + const peg$e12 = peg$literalExpectation("Added", false); + const peg$e13 = peg$literalExpectation("Changed", false); + const peg$e14 = peg$literalExpectation("Deprecated", false); + const peg$e15 = peg$literalExpectation("Removed", false); + const peg$e16 = peg$literalExpectation("Fixed", false); + const peg$e17 = peg$literalExpectation("Security", false); + const peg$e18 = peg$literalExpectation("Breaking changes", false); + const peg$e19 = peg$literalExpectation("Documentation", false); + const peg$e20 = peg$literalExpectation(".", false); + const peg$e21 = peg$classExpectation(["\r", "\n"], true, false, false); + const peg$e22 = peg$classExpectation([["0", "9"]], false, false, false); + const peg$e23 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false, false); + + function peg$f0(header, content) { return { header, content, moduleName: options.moduleName } } + function peg$f1(header, sections, subcomponents) { return { ...header, sections,subcomponents } } + function peg$f2(version, name, date) { return { type: "normal", version, date, name: name.join("").trim() } } + function peg$f3() { return { type: "unreleased" } } + function peg$f4(title, txt) { return { type: "note", title, text: txt } } + function peg$f5(type, logs) { return { type, logs } } + function peg$f6(head, sections) { return { ...head, sections } } + function peg$f7(version, name) { return { version, name: name.join("") } } + function peg$f8(name) { return { name: name.join("") } } + function peg$f9(type, logs) { return { type, logs } } + function peg$f10(log) { return log.join("") } + function peg$f11(txt) { return txt; } + function peg$f12() { return text().trim() } + function peg$f13() { return text() } + function peg$f14(major, minor, patch) { return options.Version.fromParts(major, minor, patch) } + function peg$f15(year, month, day) { return new Date(year, month - 1, day) } + function peg$f16(txt) { return txt.join("").trim() } + function peg$f17() { return parseInt(text(), 10) } + let peg$currPos = options.peg$currPos | 0; + let peg$savedPos = peg$currPos; + const peg$posDetailsCache = [{ line: 1, column: 1 }]; + let peg$maxFailPos = peg$currPos; + let peg$maxFailExpected = options.peg$maxFailExpected || []; + let peg$silentFails = options.peg$silentFails | 0; + + let peg$result; + + if (options.startRule) { if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } @@ -268,7 +262,7 @@ function peg$parse(input, options) { return { source: peg$source, start: peg$savedPos, - end: peg$currPos + end: peg$currPos, }; } @@ -296,12 +290,20 @@ function peg$parse(input, options) { throw peg$buildSimpleError(message, location); } + function peg$getUnicode(pos = peg$currPos) { + const cp = input.codePointAt(pos); + if (cp === undefined) { + return ""; + } + return String.fromCodePoint(cp); + } + function peg$literalExpectation(text, ignoreCase) { - return { type: "literal", text: text, ignoreCase: ignoreCase }; + return { type: "literal", text, ignoreCase }; } - function peg$classExpectation(parts, inverted, ignoreCase) { - return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + function peg$classExpectation(parts, inverted, ignoreCase, unicode) { + return { type: "class", parts, inverted, ignoreCase, unicode }; } function peg$anyExpectation() { @@ -313,25 +315,27 @@ function peg$parse(input, options) { } function peg$otherExpectation(description) { - return { type: "other", description: description }; + return { type: "other", description }; } function peg$computePosDetails(pos) { - var details = peg$posDetailsCache[pos]; - var p; + let details = peg$posDetailsCache[pos]; + let p; if (details) { return details; } else { - p = pos - 1; - while (!peg$posDetailsCache[p]) { - p--; + if (pos >= peg$posDetailsCache.length) { + p = peg$posDetailsCache.length - 1; + } else { + p = pos; + while (!peg$posDetailsCache[--p]) {} } details = peg$posDetailsCache[p]; details = { line: details.line, - column: details.column + column: details.column, }; while (p < pos) { @@ -351,23 +355,28 @@ function peg$parse(input, options) { } } - function peg$computeLocation(startPos, endPos) { - var startPosDetails = peg$computePosDetails(startPos); - var endPosDetails = peg$computePosDetails(endPos); + function peg$computeLocation(startPos, endPos, offset) { + const startPosDetails = peg$computePosDetails(startPos); + const endPosDetails = peg$computePosDetails(endPos); - return { + const res = { source: peg$source, start: { offset: startPos, line: startPosDetails.line, - column: startPosDetails.column + column: startPosDetails.column, }, end: { offset: endPos, line: endPosDetails.line, - column: endPosDetails.column - } + column: endPosDetails.column, + }, }; + if (offset && peg$source && (typeof peg$source.offset === "function")) { + res.start = peg$source.offset(res.start); + res.end = peg$source.offset(res.end); + } + return res; } function peg$fail(expected) { @@ -395,7 +404,7 @@ function peg$parse(input, options) { } function peg$parseChangelogFile() { - var s0, s1, s2, s3, s4; + let s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parseChangelogHead(); @@ -434,7 +443,7 @@ function peg$parse(input, options) { } function peg$parseModuleVersionEntry() { - var s0, s1, s2, s3, s4, s5, s6; + let s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = peg$parseVersionHeader(); @@ -468,7 +477,7 @@ function peg$parse(input, options) { } function peg$parseVersionHeader() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; + let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c0) { @@ -500,8 +509,8 @@ function peg$parse(input, options) { if (s5 !== peg$FAILED) { s6 = peg$parse_(); s7 = []; - if (peg$r0.test(input.charAt(peg$currPos))) { - s8 = input.charAt(peg$currPos); + s8 = input.charAt(peg$currPos); + if (peg$r0.test(s8)) { peg$currPos++; } else { s8 = peg$FAILED; @@ -509,8 +518,8 @@ function peg$parse(input, options) { } while (s8 !== peg$FAILED) { s7.push(s8); - if (peg$r0.test(input.charAt(peg$currPos))) { - s8 = input.charAt(peg$currPos); + s8 = input.charAt(peg$currPos); + if (peg$r0.test(s8)) { peg$currPos++; } else { s8 = peg$FAILED; @@ -530,8 +539,8 @@ function peg$parse(input, options) { s11 = peg$parseDate(); if (s11 !== peg$FAILED) { s12 = []; - if (peg$r1.test(input.charAt(peg$currPos))) { - s13 = input.charAt(peg$currPos); + s13 = input.charAt(peg$currPos); + if (peg$r1.test(s13)) { peg$currPos++; } else { s13 = peg$FAILED; @@ -539,8 +548,8 @@ function peg$parse(input, options) { } while (s13 !== peg$FAILED) { s12.push(s13); - if (peg$r1.test(input.charAt(peg$currPos))) { - s13 = input.charAt(peg$currPos); + s13 = input.charAt(peg$currPos); + if (peg$r1.test(s13)) { peg$currPos++; } else { s13 = peg$FAILED; @@ -578,7 +587,7 @@ function peg$parse(input, options) { } function peg$parseUnreleasedVersionHeader() { - var s0, s1, s2, s3, s4; + let s0, s1, s2, s3, s4; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c0) { @@ -614,7 +623,7 @@ function peg$parse(input, options) { } function peg$parseOtherNotes() { - var s0, s1, s2, s3, s4, s5, s6; + let s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c0) { @@ -651,7 +660,7 @@ function peg$parse(input, options) { } function peg$parseWidgetSection() { - var s0, s1, s2, s3, s4, s5, s6, s7; + let s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; s1 = peg$parse_(); @@ -697,7 +706,7 @@ function peg$parse(input, options) { } function peg$parseSubWidgetEntry() { - var s0, s1, s2, s3; + let s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parseSubComponentEntryHeaderWithVersion(); @@ -722,7 +731,7 @@ function peg$parse(input, options) { } function peg$parseSubComponentEntryHeaderWithVersion() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; s1 = peg$parse_(); @@ -755,8 +764,8 @@ function peg$parse(input, options) { if (s6 !== peg$FAILED) { s7 = peg$parse_(); s8 = []; - if (peg$r2.test(input.charAt(peg$currPos))) { - s9 = input.charAt(peg$currPos); + s9 = input.charAt(peg$currPos); + if (peg$r2.test(s9)) { peg$currPos++; } else { s9 = peg$FAILED; @@ -765,8 +774,8 @@ function peg$parse(input, options) { if (s9 !== peg$FAILED) { while (s9 !== peg$FAILED) { s8.push(s9); - if (peg$r2.test(input.charAt(peg$currPos))) { - s9 = input.charAt(peg$currPos); + s9 = input.charAt(peg$currPos); + if (peg$r2.test(s9)) { peg$currPos++; } else { s9 = peg$FAILED; @@ -804,7 +813,7 @@ function peg$parse(input, options) { } function peg$parseSubComponentEntryHeaderWithoutVersion() { - var s0, s1, s2, s3, s4, s5; + let s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parse_(); @@ -818,8 +827,8 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { s3 = peg$parse_(); s4 = []; - if (peg$r2.test(input.charAt(peg$currPos))) { - s5 = input.charAt(peg$currPos); + s5 = input.charAt(peg$currPos); + if (peg$r2.test(s5)) { peg$currPos++; } else { s5 = peg$FAILED; @@ -828,8 +837,8 @@ function peg$parse(input, options) { if (s5 !== peg$FAILED) { while (s5 !== peg$FAILED) { s4.push(s5); - if (peg$r2.test(input.charAt(peg$currPos))) { - s5 = input.charAt(peg$currPos); + s5 = input.charAt(peg$currPos); + if (peg$r2.test(s5)) { peg$currPos++; } else { s5 = peg$FAILED; @@ -855,7 +864,7 @@ function peg$parse(input, options) { } function peg$parseSubComponentSection() { - var s0, s1, s2, s3, s4, s5, s6, s7; + let s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; s1 = peg$parse_(); @@ -878,7 +887,7 @@ function peg$parse(input, options) { s7 = peg$parseLogLine(); } peg$savedPos = s0; - s0 = peg$f5(s4, s6); + s0 = peg$f9(s4, s6); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -892,7 +901,7 @@ function peg$parse(input, options) { } function peg$parseLogLine() { - var s0, s1, s2, s3, s4, s5; + let s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parse_(); @@ -906,8 +915,8 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { s3 = peg$parse_(); s4 = []; - if (peg$r2.test(input.charAt(peg$currPos))) { - s5 = input.charAt(peg$currPos); + s5 = input.charAt(peg$currPos); + if (peg$r2.test(s5)) { peg$currPos++; } else { s5 = peg$FAILED; @@ -916,8 +925,8 @@ function peg$parse(input, options) { if (s5 !== peg$FAILED) { while (s5 !== peg$FAILED) { s4.push(s5); - if (peg$r2.test(input.charAt(peg$currPos))) { - s5 = input.charAt(peg$currPos); + s5 = input.charAt(peg$currPos); + if (peg$r2.test(s5)) { peg$currPos++; } else { s5 = peg$FAILED; @@ -930,7 +939,7 @@ function peg$parse(input, options) { if (s4 !== peg$FAILED) { s5 = peg$parse_(); peg$savedPos = s0; - s0 = peg$f9(s4); + s0 = peg$f10(s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -944,7 +953,7 @@ function peg$parse(input, options) { } function peg$parseChangelogHead() { - var s0, s1, s2, s3; + let s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parseChangelogHeadLine1(); @@ -954,7 +963,7 @@ function peg$parse(input, options) { s3 = peg$parseChangelogHeadLine3(); if (s3 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f10(s2); + s0 = peg$f11(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -972,7 +981,7 @@ function peg$parse(input, options) { } function peg$parseChangelogHeadLine1() { - var s0, s1, s2, s3; + let s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse_(); @@ -996,7 +1005,7 @@ function peg$parse(input, options) { } function peg$parseChangelogHeadLine2() { - var s0, s1, s2, s3; + let s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse_(); @@ -1004,7 +1013,7 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { s3 = peg$parse_(); peg$savedPos = s0; - s0 = peg$f11(); + s0 = peg$f12(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1014,7 +1023,7 @@ function peg$parse(input, options) { } function peg$parseChangelogHeadLine3() { - var s0, s1, s2, s3; + let s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse_(); @@ -1038,7 +1047,7 @@ function peg$parse(input, options) { } function peg$parseSectionType() { - var s0, s1; + let s0, s1; if (input.substr(peg$currPos, 5) === peg$c9) { s0 = peg$c9; @@ -1106,7 +1115,7 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f12(); + s1 = peg$f13(); } s0 = s1; } @@ -1121,7 +1130,7 @@ function peg$parse(input, options) { } function peg$parseSemVer() { - var s0, s1, s2, s3, s4, s5, s6; + let s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = peg$parseNumber(); @@ -1148,7 +1157,7 @@ function peg$parse(input, options) { if (s5 !== peg$FAILED) { s6 = peg$parse_(); peg$savedPos = s0; - s0 = peg$f13(s1, s3, s5); + s0 = peg$f14(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1174,7 +1183,7 @@ function peg$parse(input, options) { } function peg$parseDate() { - var s0, s1, s2, s3, s4, s5; + let s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parseNumber(); @@ -1200,7 +1209,7 @@ function peg$parse(input, options) { s5 = peg$parseNumber(); if (s5 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f14(s1, s3, s5); + s0 = peg$f15(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1226,12 +1235,12 @@ function peg$parse(input, options) { } function peg$parseOneLineSentence() { - var s0, s1, s2; + let s0, s1, s2; s0 = peg$currPos; s1 = []; - if (peg$r3.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r3.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -1240,8 +1249,8 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$r3.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r3.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -1253,7 +1262,7 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f15(s1); + s1 = peg$f16(s1); } s0 = s1; @@ -1261,12 +1270,12 @@ function peg$parse(input, options) { } function peg$parseNumber() { - var s0, s1, s2; + let s0, s1, s2; s0 = peg$currPos; s1 = []; - if (peg$r4.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r4.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -1275,8 +1284,8 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$r4.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r4.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -1288,7 +1297,7 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f16(); + s1 = peg$f17(); } s0 = s1; @@ -1296,54 +1305,72 @@ function peg$parse(input, options) { } function peg$parse_() { - var s0, s1; + let s0, s1; peg$silentFails++; s0 = []; - if (peg$r5.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); + s1 = input.charAt(peg$currPos); + if (peg$r5.test(s1)) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e24); } + if (peg$silentFails === 0) { peg$fail(peg$e23); } } while (s1 !== peg$FAILED) { s0.push(s1); - if (peg$r5.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); + s1 = input.charAt(peg$currPos); + if (peg$r5.test(s1)) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e24); } + if (peg$silentFails === 0) { peg$fail(peg$e23); } } } peg$silentFails--; - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e23); } return s0; } peg$result = peg$startRuleFunction(); - if (peg$result !== peg$FAILED && peg$currPos === input.length) { - return peg$result; - } else { + const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length); + function peg$throw() { if (peg$result !== peg$FAILED && peg$currPos < input.length) { peg$fail(peg$endExpectation()); } throw peg$buildStructuredError( peg$maxFailExpected, - peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, + peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) ); } + if (options.peg$library) { + return /** @type {any} */ ({ + peg$result, + peg$currPos, + peg$FAILED, + peg$maxFailExpected, + peg$maxFailPos, + peg$success, + peg$throw: peg$success ? undefined : peg$throw, + }); + } + if (peg$success) { + return peg$result; + } else { + peg$throw(); + } } +const peg$allowedStartRules = [ + "ChangelogFile" +]; + export { + peg$allowedStartRules as StartRules, peg$SyntaxError as SyntaxError, peg$parse as parse }; diff --git a/automation/utils/src/changelog-parser/parser/widget/widget.mjs b/automation/utils/src/changelog-parser/parser/widget/widget.mjs index 6a193a2bd5..8c23079930 100644 --- a/automation/utils/src/changelog-parser/parser/widget/widget.mjs +++ b/automation/utils/src/changelog-parser/parser/widget/widget.mjs @@ -1,245 +1,239 @@ -// Generated by Peggy 1.2.0. +// @generated by Peggy 5.1.0. // // https://peggyjs.org/ -function peg$subclass(child, parent) { - function C() { this.constructor = child; } - C.prototype = parent.prototype; - child.prototype = new C(); -} -function peg$SyntaxError(message, expected, found, location) { - var self = Error.call(this, message); - if (Object.setPrototypeOf) { - Object.setPrototypeOf(self, peg$SyntaxError.prototype); +class peg$SyntaxError extends SyntaxError { + constructor(message, expected, found, location) { + super(message); + this.expected = expected; + this.found = found; + this.location = location; + this.name = "SyntaxError"; } - self.expected = expected; - self.found = found; - self.location = location; - self.name = "SyntaxError"; - return self; -} - -peg$subclass(peg$SyntaxError, Error); - -function peg$padEnd(str, targetLength, padString) { - padString = padString || " "; - if (str.length > targetLength) { return str; } - targetLength -= str.length; - padString += padString.repeat(targetLength); - return str + padString.slice(0, targetLength); -} -peg$SyntaxError.prototype.format = function(sources) { - var str = "Error: " + this.message; - if (this.location) { - var src = null; - var k; - for (k = 0; k < sources.length; k++) { - if (sources[k].source === this.location.source) { - src = sources[k].text.split(/\r\n|\n|\r/g); - break; + format(sources) { + let str = "Error: " + this.message; + if (this.location) { + let src = null; + const st = sources.find(s => s.source === this.location.source); + if (st) { + src = st.text.split(/\r\n|\n|\r/g); + } + const s = this.location.start; + const offset_s = (this.location.source && (typeof this.location.source.offset === "function")) + ? this.location.source.offset(s) + : s; + const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; + if (src) { + const e = this.location.end; + const filler = "".padEnd(offset_s.line.toString().length, " "); + const line = src[s.line - 1]; + const last = s.line === e.line ? e.column : line.length + 1; + const hatLen = (last - s.column) || 1; + str += "\n --> " + loc + "\n" + + filler + " |\n" + + offset_s.line + " | " + line + "\n" + + filler + " | " + "".padEnd(s.column - 1, " ") + + "".padEnd(hatLen, "^"); + } else { + str += "\n at " + loc; } } - var s = this.location.start; - var loc = this.location.source + ":" + s.line + ":" + s.column; - if (src) { - var e = this.location.end; - var filler = peg$padEnd("", s.line.toString().length); - var line = src[s.line - 1]; - var last = s.line === e.line ? e.column : line.length + 1; - str += "\n --> " + loc + "\n" - + filler + " |\n" - + s.line + " | " + line + "\n" - + filler + " | " + peg$padEnd("", s.column - 1) - + peg$padEnd("", last - s.column, "^"); - } else { - str += "\n at " + loc; - } + return str; } - return str; -}; -peg$SyntaxError.buildMessage = function(expected, found) { - var DESCRIBE_EXPECTATION_FNS = { - literal: function(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; - }, + static buildMessage(expected, found) { + function hex(ch) { + return ch.codePointAt(0).toString(16).toUpperCase(); + } - class: function(expectation) { - var escapedParts = expectation.parts.map(function(part) { - return Array.isArray(part) - ? classEscape(part[0]) + "-" + classEscape(part[1]) - : classEscape(part); - }); + const nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, "unicode") + ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu") + : null; + function unicodeEscape(s) { + if (nonPrintable) { + return s.replace(nonPrintable, ch => "\\u{" + hex(ch) + "}"); + } + return s; + } - return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; - }, + function literalEscape(s) { + return unicodeEscape(s + .replace(/\\/g, "\\\\") + .replace(/"/g, "\\\"") + .replace(/\0/g, "\\0") + .replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch)) + .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch))); + } - any: function() { - return "any character"; - }, + function classEscape(s) { + return unicodeEscape(s + .replace(/\\/g, "\\\\") + .replace(/\]/g, "\\]") + .replace(/\^/g, "\\^") + .replace(/-/g, "\\-") + .replace(/\0/g, "\\0") + .replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch)) + .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch))); + } - end: function() { - return "end of input"; - }, + const DESCRIBE_EXPECTATION_FNS = { + literal(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, - other: function(expectation) { - return expectation.description; - } - }; + class(expectation) { + const escapedParts = expectation.parts.map( + part => (Array.isArray(part) + ? classEscape(part[0]) + "-" + classEscape(part[1]) + : classEscape(part)) + ); - function hex(ch) { - return ch.charCodeAt(0).toString(16).toUpperCase(); - } + return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]" + (expectation.unicode ? "u" : ""); + }, - function literalEscape(s) { - return s - .replace(/\\/g, "\\\\") - .replace(/"/g, "\\\"") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); - } + any() { + return "any character"; + }, - function classEscape(s) { - return s - .replace(/\\/g, "\\\\") - .replace(/\]/g, "\\]") - .replace(/\^/g, "\\^") - .replace(/-/g, "\\-") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); - } + end() { + return "end of input"; + }, - function describeExpectation(expectation) { - return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); - } + other(expectation) { + return expectation.description; + }, + }; - function describeExpected(expected) { - var descriptions = expected.map(describeExpectation); - var i, j; + function describeExpectation(expectation) { + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } - descriptions.sort(); + function describeExpected(expected) { + const descriptions = expected.map(describeExpectation); + descriptions.sort(); - if (descriptions.length > 0) { - for (i = 1, j = 1; i < descriptions.length; i++) { - if (descriptions[i - 1] !== descriptions[i]) { - descriptions[j] = descriptions[i]; - j++; + if (descriptions.length > 0) { + let j = 1; + for (let i = 1; i < descriptions.length; i++) { + if (descriptions[i - 1] !== descriptions[i]) { + descriptions[j] = descriptions[i]; + j++; + } } + descriptions.length = j; } - descriptions.length = j; - } - switch (descriptions.length) { - case 1: - return descriptions[0]; + switch (descriptions.length) { + case 1: + return descriptions[0]; - case 2: - return descriptions[0] + " or " + descriptions[1]; + case 2: + return descriptions[0] + " or " + descriptions[1]; - default: - return descriptions.slice(0, -1).join(", ") - + ", or " - + descriptions[descriptions.length - 1]; + default: + return descriptions.slice(0, -1).join(", ") + + ", or " + + descriptions[descriptions.length - 1]; + } } - } - function describeFound(found) { - return found ? "\"" + literalEscape(found) + "\"" : "end of input"; - } + function describeFound(found) { + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } - return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; -}; + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; + } +} function peg$parse(input, options) { options = options !== undefined ? options : {}; - var peg$FAILED = {}; - var peg$source = options.grammarSource; - - var peg$startRuleFunctions = { ChangelogFile: peg$parseChangelogFile }; - var peg$startRuleFunction = peg$parseChangelogFile; - - var peg$c0 = "##"; - var peg$c1 = "["; - var peg$c2 = "]"; - var peg$c3 = "-"; - var peg$c4 = "[Unreleased]"; - var peg$c5 = "Older releases"; - var peg$c6 = "###"; - var peg$c7 = "# Changelog"; - var peg$c8 = "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)."; - var peg$c9 = "Added"; - var peg$c10 = "Changed"; - var peg$c11 = "Deprecated"; - var peg$c12 = "Removed"; - var peg$c13 = "Fixed"; - var peg$c14 = "Security"; - var peg$c15 = "Breaking changes"; - var peg$c16 = "Documentation"; - var peg$c17 = "."; - - var peg$r0 = /^[^\r\n]/; - var peg$r1 = /^[0-9]/; - var peg$r2 = /^[ \t\n\r]/; - - var peg$e0 = peg$literalExpectation("##", false); - var peg$e1 = peg$literalExpectation("[", false); - var peg$e2 = peg$literalExpectation("]", false); - var peg$e3 = peg$literalExpectation("-", false); - var peg$e4 = peg$literalExpectation("[Unreleased]", false); - var peg$e5 = peg$literalExpectation("Older releases", false); - var peg$e6 = peg$literalExpectation("###", false); - var peg$e7 = peg$literalExpectation("# Changelog", false); - var peg$e8 = peg$literalExpectation("The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).", false); - var peg$e9 = peg$literalExpectation("Added", false); - var peg$e10 = peg$literalExpectation("Changed", false); - var peg$e11 = peg$literalExpectation("Deprecated", false); - var peg$e12 = peg$literalExpectation("Removed", false); - var peg$e13 = peg$literalExpectation("Fixed", false); - var peg$e14 = peg$literalExpectation("Security", false); - var peg$e15 = peg$literalExpectation("Breaking changes", false); - var peg$e16 = peg$literalExpectation("Documentation", false); - var peg$e17 = peg$literalExpectation(".", false); - var peg$e18 = peg$classExpectation(["\r", "\n"], true, false); - var peg$e19 = peg$classExpectation([["0", "9"]], false, false); - var peg$e20 = peg$otherExpectation("whitespace"); - var peg$e21 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false); - - var peg$f0 = function(header, content) { return { header, content } }; - var peg$f1 = function(header, sections) { return { ...header, sections } }; - var peg$f2 = function(version, date) { return { type: "normal", version, date }}; - var peg$f3 = function() { return { type: "unreleased" }}; - var peg$f4 = function(title, txt) { return { type: "note", title, text: txt }}; - var peg$f5 = function(type, logs) { return { type, logs } }; - var peg$f6 = function(log) { return log }; - var peg$f7 = function(txt) { return txt; }; - var peg$f8 = function() { return text().trim() }; - var peg$f9 = function() { return text() }; - var peg$f10 = function(major, minor, patch) { return options.Version.fromParts(major, minor, patch) }; - var peg$f11 = function(year, month, day) { return new Date(year, month - 1, day) }; - var peg$f12 = function(txt) { return txt.join("").trim() }; - var peg$f13 = function() { return parseInt(text(), 10) }; - - var peg$currPos = 0; - var peg$savedPos = 0; - var peg$posDetailsCache = [{ line: 1, column: 1 }]; - var peg$maxFailPos = 0; - var peg$maxFailExpected = []; - var peg$silentFails = 0; - - var peg$result; - - if ("startRule" in options) { + const peg$FAILED = {}; + const peg$source = options.grammarSource; + + const peg$startRuleFunctions = { + ChangelogFile: peg$parseChangelogFile, + }; + let peg$startRuleFunction = peg$parseChangelogFile; + + const peg$c0 = "##"; + const peg$c1 = "["; + const peg$c2 = "]"; + const peg$c3 = "-"; + const peg$c4 = "[Unreleased]"; + const peg$c5 = "Older releases"; + const peg$c6 = "###"; + const peg$c7 = "# Changelog"; + const peg$c8 = "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)."; + const peg$c9 = "Added"; + const peg$c10 = "Changed"; + const peg$c11 = "Deprecated"; + const peg$c12 = "Removed"; + const peg$c13 = "Fixed"; + const peg$c14 = "Security"; + const peg$c15 = "Breaking changes"; + const peg$c16 = "Documentation"; + const peg$c17 = "."; + + const peg$r0 = /^[^\r\n]/; + const peg$r1 = /^[0-9]/; + const peg$r2 = /^[ \t\n\r]/; + + const peg$e0 = peg$literalExpectation("##", false); + const peg$e1 = peg$literalExpectation("[", false); + const peg$e2 = peg$literalExpectation("]", false); + const peg$e3 = peg$literalExpectation("-", false); + const peg$e4 = peg$literalExpectation("[Unreleased]", false); + const peg$e5 = peg$literalExpectation("Older releases", false); + const peg$e6 = peg$literalExpectation("###", false); + const peg$e7 = peg$literalExpectation("# Changelog", false); + const peg$e8 = peg$literalExpectation("The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).", false); + const peg$e9 = peg$literalExpectation("Added", false); + const peg$e10 = peg$literalExpectation("Changed", false); + const peg$e11 = peg$literalExpectation("Deprecated", false); + const peg$e12 = peg$literalExpectation("Removed", false); + const peg$e13 = peg$literalExpectation("Fixed", false); + const peg$e14 = peg$literalExpectation("Security", false); + const peg$e15 = peg$literalExpectation("Breaking changes", false); + const peg$e16 = peg$literalExpectation("Documentation", false); + const peg$e17 = peg$literalExpectation(".", false); + const peg$e18 = peg$classExpectation(["\r", "\n"], true, false, false); + const peg$e19 = peg$classExpectation([["0", "9"]], false, false, false); + const peg$e20 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false, false); + + function peg$f0(header, content) { return { header, content } } + function peg$f1(header, sections) { return { ...header, sections } } + function peg$f2(header, sections) { return { ...header, sections } } + function peg$f3(version, date) { return { type: "normal", version, date } } + function peg$f4() { return { type: "unreleased" } } + function peg$f5(title, txt) { return { type: "note", title, text: txt } } + function peg$f6(type, logs) { return { type, logs } } + function peg$f7(log) { return log } + function peg$f8(txt) { return txt; } + function peg$f9() { return text().trim() } + function peg$f10() { return text() } + function peg$f11(major, minor, patch) { return options.Version.fromParts(major, minor, patch) } + function peg$f12(year, month, day) { return new Date(year, month - 1, day) } + function peg$f13(txt) { return txt.join("").trim() } + function peg$f14() { return parseInt(text(), 10) } + let peg$currPos = options.peg$currPos | 0; + let peg$savedPos = peg$currPos; + const peg$posDetailsCache = [{ line: 1, column: 1 }]; + let peg$maxFailPos = peg$currPos; + let peg$maxFailExpected = options.peg$maxFailExpected || []; + let peg$silentFails = options.peg$silentFails | 0; + + let peg$result; + + if (options.startRule) { if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } @@ -259,7 +253,7 @@ function peg$parse(input, options) { return { source: peg$source, start: peg$savedPos, - end: peg$currPos + end: peg$currPos, }; } @@ -287,12 +281,20 @@ function peg$parse(input, options) { throw peg$buildSimpleError(message, location); } + function peg$getUnicode(pos = peg$currPos) { + const cp = input.codePointAt(pos); + if (cp === undefined) { + return ""; + } + return String.fromCodePoint(cp); + } + function peg$literalExpectation(text, ignoreCase) { - return { type: "literal", text: text, ignoreCase: ignoreCase }; + return { type: "literal", text, ignoreCase }; } - function peg$classExpectation(parts, inverted, ignoreCase) { - return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + function peg$classExpectation(parts, inverted, ignoreCase, unicode) { + return { type: "class", parts, inverted, ignoreCase, unicode }; } function peg$anyExpectation() { @@ -304,25 +306,27 @@ function peg$parse(input, options) { } function peg$otherExpectation(description) { - return { type: "other", description: description }; + return { type: "other", description }; } function peg$computePosDetails(pos) { - var details = peg$posDetailsCache[pos]; - var p; + let details = peg$posDetailsCache[pos]; + let p; if (details) { return details; } else { - p = pos - 1; - while (!peg$posDetailsCache[p]) { - p--; + if (pos >= peg$posDetailsCache.length) { + p = peg$posDetailsCache.length - 1; + } else { + p = pos; + while (!peg$posDetailsCache[--p]) {} } details = peg$posDetailsCache[p]; details = { line: details.line, - column: details.column + column: details.column, }; while (p < pos) { @@ -342,23 +346,28 @@ function peg$parse(input, options) { } } - function peg$computeLocation(startPos, endPos) { - var startPosDetails = peg$computePosDetails(startPos); - var endPosDetails = peg$computePosDetails(endPos); + function peg$computeLocation(startPos, endPos, offset) { + const startPosDetails = peg$computePosDetails(startPos); + const endPosDetails = peg$computePosDetails(endPos); - return { + const res = { source: peg$source, start: { offset: startPos, line: startPosDetails.line, - column: startPosDetails.column + column: startPosDetails.column, }, end: { offset: endPos, line: endPosDetails.line, - column: endPosDetails.column - } + column: endPosDetails.column, + }, }; + if (offset && peg$source && (typeof peg$source.offset === "function")) { + res.start = peg$source.offset(res.start); + res.end = peg$source.offset(res.end); + } + return res; } function peg$fail(expected) { @@ -386,7 +395,7 @@ function peg$parse(input, options) { } function peg$parseChangelogFile() { - var s0, s1, s2, s3, s4; + let s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parseChangelogHead(); @@ -431,7 +440,7 @@ function peg$parse(input, options) { } function peg$parseUnreleasedVersionEntry() { - var s0, s1, s2, s3, s4; + let s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parseUnreleasedVersionHeader(); @@ -455,7 +464,7 @@ function peg$parse(input, options) { } function peg$parseReleasedVersionEntry() { - var s0, s1, s2, s3, s4; + let s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parseVersionHeader(); @@ -477,7 +486,7 @@ function peg$parse(input, options) { if (s3 !== peg$FAILED) { s4 = peg$parse_(); peg$savedPos = s0; - s0 = peg$f1(s1, s3); + s0 = peg$f2(s1, s3); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -491,7 +500,7 @@ function peg$parse(input, options) { } function peg$parseVersionHeader() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c0) { @@ -534,7 +543,7 @@ function peg$parse(input, options) { s9 = peg$parseDate(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f2(s4, s9); + s0 = peg$f3(s4, s9); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -564,7 +573,7 @@ function peg$parse(input, options) { } function peg$parseUnreleasedVersionHeader() { - var s0, s1, s2, s3, s4; + let s0, s1, s2, s3, s4; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c0) { @@ -586,7 +595,7 @@ function peg$parse(input, options) { if (s3 !== peg$FAILED) { s4 = peg$parse_(); peg$savedPos = s0; - s0 = peg$f3(); + s0 = peg$f4(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -600,7 +609,7 @@ function peg$parse(input, options) { } function peg$parseOtherNotes() { - var s0, s1, s2, s3, s4, s5, s6; + let s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c0) { @@ -634,7 +643,7 @@ function peg$parse(input, options) { if (s5 !== peg$FAILED) { s6 = peg$parse_(); peg$savedPos = s0; - s0 = peg$f4(s3, s5); + s0 = peg$f5(s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -652,7 +661,7 @@ function peg$parse(input, options) { } function peg$parseWidgetSection() { - var s0, s1, s2, s3, s4, s5, s6, s7; + let s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; s1 = peg$parse_(); @@ -680,7 +689,7 @@ function peg$parse(input, options) { } if (s6 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f5(s4, s6); + s0 = peg$f6(s4, s6); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -698,7 +707,7 @@ function peg$parse(input, options) { } function peg$parseLogLine() { - var s0, s1, s2, s3, s4, s5; + let s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parse_(); @@ -715,7 +724,7 @@ function peg$parse(input, options) { if (s4 !== peg$FAILED) { s5 = peg$parse_(); peg$savedPos = s0; - s0 = peg$f6(s4); + s0 = peg$f7(s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -729,7 +738,7 @@ function peg$parse(input, options) { } function peg$parseChangelogHead() { - var s0, s1, s2, s3; + let s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parseChangelogHeadLine1(); @@ -739,7 +748,7 @@ function peg$parse(input, options) { s3 = peg$parseChangelogHeadLine3(); if (s3 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f7(s2); + s0 = peg$f8(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -757,7 +766,7 @@ function peg$parse(input, options) { } function peg$parseChangelogHeadLine1() { - var s0, s1, s2, s3; + let s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse_(); @@ -781,7 +790,7 @@ function peg$parse(input, options) { } function peg$parseChangelogHeadLine2() { - var s0, s1, s2, s3; + let s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse_(); @@ -789,7 +798,7 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { s3 = peg$parse_(); peg$savedPos = s0; - s0 = peg$f8(); + s0 = peg$f9(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -799,7 +808,7 @@ function peg$parse(input, options) { } function peg$parseChangelogHeadLine3() { - var s0, s1, s2, s3; + let s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse_(); @@ -823,7 +832,7 @@ function peg$parse(input, options) { } function peg$parseSectionType() { - var s0, s1; + let s0, s1; if (input.substr(peg$currPos, 5) === peg$c9) { s0 = peg$c9; @@ -891,7 +900,7 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f9(); + s1 = peg$f10(); } s0 = s1; } @@ -906,7 +915,7 @@ function peg$parse(input, options) { } function peg$parseSemVer() { - var s0, s1, s2, s3, s4, s5, s6; + let s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = peg$parseNumber(); @@ -933,7 +942,7 @@ function peg$parse(input, options) { if (s5 !== peg$FAILED) { s6 = peg$parse_(); peg$savedPos = s0; - s0 = peg$f10(s1, s3, s5); + s0 = peg$f11(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -959,7 +968,7 @@ function peg$parse(input, options) { } function peg$parseDate() { - var s0, s1, s2, s3, s4, s5; + let s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parseNumber(); @@ -985,7 +994,7 @@ function peg$parse(input, options) { s5 = peg$parseNumber(); if (s5 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f11(s1, s3, s5); + s0 = peg$f12(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1011,12 +1020,12 @@ function peg$parse(input, options) { } function peg$parseOneLineSentence() { - var s0, s1, s2; + let s0, s1, s2; s0 = peg$currPos; s1 = []; - if (peg$r0.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -1025,8 +1034,8 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$r0.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -1038,7 +1047,7 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f12(s1); + s1 = peg$f13(s1); } s0 = s1; @@ -1046,12 +1055,12 @@ function peg$parse(input, options) { } function peg$parseNumber() { - var s0, s1, s2; + let s0, s1, s2; s0 = peg$currPos; s1 = []; - if (peg$r1.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r1.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -1060,8 +1069,8 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$r1.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r1.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -1073,7 +1082,7 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f13(); + s1 = peg$f14(); } s0 = s1; @@ -1081,54 +1090,72 @@ function peg$parse(input, options) { } function peg$parse_() { - var s0, s1; + let s0, s1; peg$silentFails++; s0 = []; - if (peg$r2.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); + s1 = input.charAt(peg$currPos); + if (peg$r2.test(s1)) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e21); } + if (peg$silentFails === 0) { peg$fail(peg$e20); } } while (s1 !== peg$FAILED) { s0.push(s1); - if (peg$r2.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); + s1 = input.charAt(peg$currPos); + if (peg$r2.test(s1)) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e21); } + if (peg$silentFails === 0) { peg$fail(peg$e20); } } } peg$silentFails--; - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e20); } return s0; } peg$result = peg$startRuleFunction(); - if (peg$result !== peg$FAILED && peg$currPos === input.length) { - return peg$result; - } else { + const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length); + function peg$throw() { if (peg$result !== peg$FAILED && peg$currPos < input.length) { peg$fail(peg$endExpectation()); } throw peg$buildStructuredError( peg$maxFailExpected, - peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, + peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) ); } + if (options.peg$library) { + return /** @type {any} */ ({ + peg$result, + peg$currPos, + peg$FAILED, + peg$maxFailExpected, + peg$maxFailPos, + peg$success, + peg$throw: peg$success ? undefined : peg$throw, + }); + } + if (peg$success) { + return peg$result; + } else { + peg$throw(); + } } +const peg$allowedStartRules = [ + "ChangelogFile" +]; + export { + peg$allowedStartRules as StartRules, peg$SyntaxError as SyntaxError, peg$parse as parse }; From c88cd6bbe5f2b1c1745ea373d9517a9c10409a28 Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Fri, 23 Oct 2026 12:01:33 +0200 Subject: [PATCH 08/14] chore(mcp): run MCP servers from source with native type stripping --- .mcp.json | 2 +- automation/e2e-mcp/.gitignore | 2 -- automation/e2e-mcp/package.json | 11 +++++------ automation/e2e-mcp/src/index.ts | 0 automation/e2e-mcp/tsconfig.json | 17 +++++++---------- automation/marketplace-mcp/package.json | 11 +++++------ automation/marketplace-mcp/src/index.ts | 0 automation/marketplace-mcp/tsconfig.json | 17 +++++++---------- 8 files changed, 25 insertions(+), 35 deletions(-) mode change 100644 => 100755 automation/e2e-mcp/src/index.ts mode change 100644 => 100755 automation/marketplace-mcp/src/index.ts diff --git a/.mcp.json b/.mcp.json index 89e716f7f7..9e9164ddfb 100644 --- a/.mcp.json +++ b/.mcp.json @@ -3,7 +3,7 @@ "marketplace-mcp": { "type": "stdio", "command": "node", - "args": ["./automation/marketplace-mcp/dist/index.js"], + "args": ["./automation/marketplace-mcp/src/index.ts"], "env": { "MX_PAT": "${MARKETPLACE_API_TOKEN}" } diff --git a/automation/e2e-mcp/.gitignore b/automation/e2e-mcp/.gitignore index f4e2c6d6b8..c2658d7d1b 100644 --- a/automation/e2e-mcp/.gitignore +++ b/automation/e2e-mcp/.gitignore @@ -1,3 +1 @@ node_modules/ -dist/ -*.tsbuildinfo diff --git a/automation/e2e-mcp/package.json b/automation/e2e-mcp/package.json index 850d01a2c9..cbdeb1c386 100644 --- a/automation/e2e-mcp/package.json +++ b/automation/e2e-mcp/package.json @@ -2,16 +2,15 @@ "name": "@mendix/e2e-mcp", "version": "0.1.0", "description": "MCP server for Mendix E2E test triage – surfaces flaky, slow and failing tests from CTRF reports to GitHub Copilot.", + "private": true, "bin": { - "e2e-mcp": "dist/index.js" + "e2e-mcp": "src/index.ts" }, "type": "module", - "main": "dist/index.js", + "main": "src/index.ts", "scripts": { - "build": "tsc", - "dev": "tsc --watch", - "postinstall": "tsc", - "start": "node dist/index.js" + "lint": "tsc", + "start": "node src/index.ts" }, "dependencies": { "@modelcontextprotocol/sdk": "^1.31.0", diff --git a/automation/e2e-mcp/src/index.ts b/automation/e2e-mcp/src/index.ts old mode 100644 new mode 100755 diff --git a/automation/e2e-mcp/tsconfig.json b/automation/e2e-mcp/tsconfig.json index 78f34baa8e..5d40562a26 100644 --- a/automation/e2e-mcp/tsconfig.json +++ b/automation/e2e-mcp/tsconfig.json @@ -1,18 +1,15 @@ { "compilerOptions": { "target": "ES2022", - "module": "Node16", - "moduleResolution": "Node16", - "outDir": "./dist", - "rootDir": "./src", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "noEmit": true, + "allowImportingTsExtensions": true, + "erasableSyntaxOnly": true, + "verbatimModuleSyntax": true, "strict": true, - "esModuleInterop": true, "skipLibCheck": true, - "declaration": true, - "declarationMap": true, - "sourceMap": true, "types": ["node"] }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] + "include": ["src/**/*"] } diff --git a/automation/marketplace-mcp/package.json b/automation/marketplace-mcp/package.json index 787a4abdae..9d1e3c9dab 100644 --- a/automation/marketplace-mcp/package.json +++ b/automation/marketplace-mcp/package.json @@ -2,16 +2,15 @@ "name": "@mendix/marketplace-mcp", "version": "0.1.0", "description": "MCP server for the Mendix Marketplace Content API – browse and query Marketplace content from your Agent.", + "private": true, "bin": { - "marketplace-mcp": "dist/index.js" + "marketplace-mcp": "src/index.ts" }, "type": "module", - "main": "dist/index.js", + "main": "src/index.ts", "scripts": { - "build": "tsc", - "dev": "tsc --watch", - "postinstall": "tsc", - "start": "node dist/index.js" + "lint": "tsc", + "start": "node src/index.ts" }, "dependencies": { "@modelcontextprotocol/sdk": "^1.31.0", diff --git a/automation/marketplace-mcp/src/index.ts b/automation/marketplace-mcp/src/index.ts old mode 100644 new mode 100755 diff --git a/automation/marketplace-mcp/tsconfig.json b/automation/marketplace-mcp/tsconfig.json index 78f34baa8e..5d40562a26 100644 --- a/automation/marketplace-mcp/tsconfig.json +++ b/automation/marketplace-mcp/tsconfig.json @@ -1,18 +1,15 @@ { "compilerOptions": { "target": "ES2022", - "module": "Node16", - "moduleResolution": "Node16", - "outDir": "./dist", - "rootDir": "./src", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "noEmit": true, + "allowImportingTsExtensions": true, + "erasableSyntaxOnly": true, + "verbatimModuleSyntax": true, "strict": true, - "esModuleInterop": true, "skipLibCheck": true, - "declaration": true, - "declarationMap": true, - "sourceMap": true, "types": ["node"] }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] + "include": ["src/**/*"] } From cdce329de012e24e6988884fb6885a25e7c399c0 Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Fri, 23 Oct 2026 12:09:35 +0200 Subject: [PATCH 09/14] chore(automation-utils): lint bin, entry files and package.json --- automation/utils/bin/rui-check-changelogs.ts | 2 +- automation/utils/bin/rui-create-translation.ts | 6 ++---- automation/utils/bin/rui-oss-clearance.ts | 2 +- automation/utils/bin/rui-prepare-release.ts | 2 +- automation/utils/bin/rui-verify-package-format.ts | 2 +- automation/utils/package.json | 6 +++--- automation/utils/tsconfig.json | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/automation/utils/bin/rui-check-changelogs.ts b/automation/utils/bin/rui-check-changelogs.ts index f95acf7a1a..fa535d654c 100644 --- a/automation/utils/bin/rui-check-changelogs.ts +++ b/automation/utils/bin/rui-check-changelogs.ts @@ -106,7 +106,7 @@ async function getChangedFiles(baseSha: string, mergedTreeSha: string): Promise< * the SHA of the resulting tree. */ async function getMergedTreeSha(baseSha: string, headSha: string): Promise { - let stdout = ""; + let stdout: string; let hasConflicts = false; try { diff --git a/automation/utils/bin/rui-create-translation.ts b/automation/utils/bin/rui-create-translation.ts index 77337524d0..55d4489d42 100755 --- a/automation/utils/bin/rui-create-translation.ts +++ b/automation/utils/bin/rui-create-translation.ts @@ -43,10 +43,8 @@ export async function createTranslation(cwd: string) { if (widgetXMLName) { const obj = await readXml(path.join(cwd, "src", widgetXMLName)); const res = findCaptionsAndDescriptions(obj); - let fileName = "result"; - if (obj && typeof obj === "object" && obj["widget"] && obj["widget"]["@_id"]) { - fileName = obj["widget"]["@_id"].toLowerCase(); - } + const widgetId = (obj as { widget?: { "@_id"?: string } } | undefined)?.widget?.["@_id"]; + const fileName = widgetId ? widgetId.toLowerCase() : "result"; writeResultToFile(res, `dist/locales/en-US/${fileName}.json`); writeResultToFile(res, `../../../dist/locales/en-US/${fileName}.json`); } diff --git a/automation/utils/bin/rui-oss-clearance.ts b/automation/utils/bin/rui-oss-clearance.ts index ec5fea26c0..c8eb884b80 100755 --- a/automation/utils/bin/rui-oss-clearance.ts +++ b/automation/utils/bin/rui-oss-clearance.ts @@ -86,7 +86,7 @@ async function verifyGitHubAuth(): Promise { console.log(chalk.cyan(" • Option C: gh auth login\n")); console.log(chalk.white("3. For A and B get your token at:")); console.log(chalk.cyan(" https://github.com/settings/tokens\n")); - throw new Error("GitHub authentication required"); + throw new Error("GitHub authentication required", { cause: error }); } } diff --git a/automation/utils/bin/rui-prepare-release.ts b/automation/utils/bin/rui-prepare-release.ts index 35e763ff5d..532d8d9f58 100755 --- a/automation/utils/bin/rui-prepare-release.ts +++ b/automation/utils/bin/rui-prepare-release.ts @@ -392,7 +392,7 @@ async function initializeJiraClient(): Promise { console.log(chalk.green("✅ Jira project data initialized")); } catch (error) { console.error(chalk.red(`❌ Jira init failed: ${(error as Error).message}`)); - throw new Error("Jira initialization failed"); + throw new Error("Jira initialization failed", { cause: error }); } return jira; diff --git a/automation/utils/bin/rui-verify-package-format.ts b/automation/utils/bin/rui-verify-package-format.ts index 8ab64b18b2..6bb301e07e 100755 --- a/automation/utils/bin/rui-verify-package-format.ts +++ b/automation/utils/bin/rui-verify-package-format.ts @@ -74,7 +74,7 @@ async function main(): Promise { } // Just for new line console.log(""); - throw new Error("Verification failed"); + throw new Error("Verification failed", { cause: error }); } throw error; diff --git a/automation/utils/package.json b/automation/utils/package.json index d0505dea2c..ce59e31868 100644 --- a/automation/utils/package.json +++ b/automation/utils/package.json @@ -33,9 +33,9 @@ ".": "./index.ts", "./shell": "./shell.ts", "./steps": "./steps.ts", - "./utils": "./utils.ts", "./tsconfig": "./tsconfig.json", - "./tsconfig.json": "./tsconfig.json" + "./tsconfig.json": "./tsconfig.json", + "./utils": "./utils.ts" }, "scripts": { "changelog": "node bin/rui-changelog-helper.ts", @@ -45,7 +45,7 @@ "compile:parser:widget": "peggy --format es -o ./src/changelog-parser/parser/widget/widget.mjs ./src/changelog-parser/parser/widget/widget.pegjs", "format": "prettier --write .", "include-oss-in-artifact": "node bin/rui-include-oss-in-artifact.ts", - "lint": "eslint --ext .jsx,.js,.ts,.tsx src/", + "lint": "eslint . package.json", "merge-changelogs-pr": "node bin/rui-merge-changelogs-pr.ts", "oss-clearance": "node bin/rui-oss-clearance.ts", "prepare": "tsc", diff --git a/automation/utils/tsconfig.json b/automation/utils/tsconfig.json index e6a78385d4..91e826e8cb 100644 --- a/automation/utils/tsconfig.json +++ b/automation/utils/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["./src", "./bin"], + "include": ["./*.ts", "./src", "./bin"], "compilerOptions": { "lib": ["ES2022"], "module": "NodeNext", From bb40bef67809f0b8660d36a211932d2a422f43f9 Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Fri, 23 Oct 2026 12:09:37 +0200 Subject: [PATCH 10/14] chore(eslint-config-web-widgets): remove broken unused .prettierrc.mjs --- packages/shared/eslint-config-web-widgets/.prettierrc.mjs | 1 - 1 file changed, 1 deletion(-) delete mode 100644 packages/shared/eslint-config-web-widgets/.prettierrc.mjs diff --git a/packages/shared/eslint-config-web-widgets/.prettierrc.mjs b/packages/shared/eslint-config-web-widgets/.prettierrc.mjs deleted file mode 100644 index 00fd439fe0..0000000000 --- a/packages/shared/eslint-config-web-widgets/.prettierrc.mjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("@mendix/prettier-config-web-widgets/index.mjs"); From 82b123f0d772549f84a3405166df112a8e78dded Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Fri, 23 Oct 2026 12:09:38 +0200 Subject: [PATCH 11/14] chore(calendar-web): use standard lint script --- packages/pluggableWidgets/calendar-web/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pluggableWidgets/calendar-web/package.json b/packages/pluggableWidgets/calendar-web/package.json index 1021b86291..17408a004f 100644 --- a/packages/pluggableWidgets/calendar-web/package.json +++ b/packages/pluggableWidgets/calendar-web/package.json @@ -33,7 +33,7 @@ "e2e": "echo \"Skipping this e2e test\"", "e2edev": "run-e2e dev --with-preps", "format": "pluggable-widgets-tools format", - "lint": "eslint --ext .jsx,.js,.ts,.tsx src/", + "lint": "eslint src/ package.json", "publish-marketplace": "rui-publish-marketplace", "release": "cross-env MPKOUTPUT=Calendar.mpk pluggable-widgets-tools release:web", "start": "cross-env MPKOUTPUT=Calendar.mpk pluggable-widgets-tools start:server", From 71083a863ae47359d5a6f62e1c35d78fdb56bbd7 Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Fri, 23 Oct 2026 12:09:39 +0200 Subject: [PATCH 12/14] chore(scripts): enable eslint --- automation/scripts/eslint.config.mjs | 25 +++++++++++++++++++++++++ automation/scripts/package.json | 3 +-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 automation/scripts/eslint.config.mjs diff --git a/automation/scripts/eslint.config.mjs b/automation/scripts/eslint.config.mjs new file mode 100644 index 0000000000..016589e0fe --- /dev/null +++ b/automation/scripts/eslint.config.mjs @@ -0,0 +1,25 @@ +import { defineConfig } from "eslint/config"; +import globals from "globals"; +import js from "@eslint/js"; + +export default defineConfig([ + { + files: ["**/*.{,m,c}js"], + languageOptions: { + globals: { + ...globals.node, + ...globals.es2021 + }, + ecmaVersion: 2021, + sourceType: "module" + } + }, + { + files: ["**/*.{,m,c}js"], + plugins: { js }, + extends: ["js/recommended"], + rules: { + "no-unused-vars": "warn" + } + } +]); diff --git a/automation/scripts/package.json b/automation/scripts/package.json index b8f2187d36..5e4c5cbe19 100644 --- a/automation/scripts/package.json +++ b/automation/scripts/package.json @@ -11,8 +11,7 @@ "type": "module", "scripts": { "format": "prettier --write .", - "lint": "echo 'Lint disabled for now, please update package scripts'", - "lint:enableme": "eslint . --ext .mjs", + "lint": "eslint .", "root-script:commitlint": "commitlint", "root-script:format-staged": "pretty-quick --staged --config \"./.prettierrc.cjs\" --pattern \"**/{src,script,typings,test,**}/**/*.{cjs,mjs,js,jsx,ts,tsx,scss,xml,md,json}\"", "update-screenshots": "node update-screenshots.mjs", From 817959e7019761440542aca1ed71785e0634e4b0 Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Fri, 23 Oct 2026 12:10:29 +0200 Subject: [PATCH 13/14] docs(automation-utils): note how to regenerate committed changelog parsers --- .../utils/src/changelog-parser/parser/module/module.pegjs | 3 +++ .../utils/src/changelog-parser/parser/widget/widget.pegjs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/automation/utils/src/changelog-parser/parser/module/module.pegjs b/automation/utils/src/changelog-parser/parser/module/module.pegjs index 8f2f4a1604..ae54cbd9ae 100644 --- a/automation/utils/src/changelog-parser/parser/module/module.pegjs +++ b/automation/utils/src/changelog-parser/parser/module/module.pegjs @@ -1,6 +1,9 @@ // Simple Changelog Grammar // ========================== // +// The generated parser (module.mjs) is committed. After editing this grammar, +// regenerate it with `pnpm run compile:parser` and commit both files. +// ChangelogFile = header:ChangelogHead _ content:(ModuleVersionEntry / OtherNotes)+ _ { return { header, content, moduleName: options.moduleName } } diff --git a/automation/utils/src/changelog-parser/parser/widget/widget.pegjs b/automation/utils/src/changelog-parser/parser/widget/widget.pegjs index 670faf0988..ae11800ee6 100644 --- a/automation/utils/src/changelog-parser/parser/widget/widget.pegjs +++ b/automation/utils/src/changelog-parser/parser/widget/widget.pegjs @@ -1,6 +1,9 @@ // Simple Changelog Grammar // ========================== // +// The generated parser (widget.mjs) is committed. After editing this grammar, +// regenerate it with `pnpm run compile:parser` and commit both files. +// ChangelogFile = header:ChangelogHead _ content:(UnreleasedVersionEntry/ReleasedVersionEntry/OtherNotes)+ _ { return { header, content } } From 051271bc7f16e214b8e4f2ca42aa47ff2516817f Mon Sep 17 00:00:00 2001 From: Roman Vyakhirev Date: Fri, 23 Oct 2026 13:15:38 +0200 Subject: [PATCH 14/14] chore(automation-utils): unify bin shebangs and modes, drop emit options rui-prepare-release.ts was the only bin without a shebang, and three bins were not executable. tsconfig has noEmit, so outDir, declaration and noEmitOnError had no effect. --- automation/utils/bin/rui-changelog-helper.ts | 0 automation/utils/bin/rui-changelog.ts | 0 automation/utils/bin/rui-check-changelogs.ts | 0 automation/utils/bin/rui-prepare-release.ts | 1 + automation/utils/tsconfig.json | 5 +---- 5 files changed, 2 insertions(+), 4 deletions(-) mode change 100644 => 100755 automation/utils/bin/rui-changelog-helper.ts mode change 100644 => 100755 automation/utils/bin/rui-changelog.ts mode change 100644 => 100755 automation/utils/bin/rui-check-changelogs.ts diff --git a/automation/utils/bin/rui-changelog-helper.ts b/automation/utils/bin/rui-changelog-helper.ts old mode 100644 new mode 100755 diff --git a/automation/utils/bin/rui-changelog.ts b/automation/utils/bin/rui-changelog.ts old mode 100644 new mode 100755 diff --git a/automation/utils/bin/rui-check-changelogs.ts b/automation/utils/bin/rui-check-changelogs.ts old mode 100644 new mode 100755 diff --git a/automation/utils/bin/rui-prepare-release.ts b/automation/utils/bin/rui-prepare-release.ts index 532d8d9f58..35e9b6ea7a 100755 --- a/automation/utils/bin/rui-prepare-release.ts +++ b/automation/utils/bin/rui-prepare-release.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env node import chalk from "chalk"; import enquirer from "enquirer"; import { bumpPackageJson, bumpXml, getNextVersion } from "../src/bump-version.ts"; diff --git a/automation/utils/tsconfig.json b/automation/utils/tsconfig.json index 91e826e8cb..f963d82685 100644 --- a/automation/utils/tsconfig.json +++ b/automation/utils/tsconfig.json @@ -9,17 +9,14 @@ "erasableSyntaxOnly": true, "verbatimModuleSyntax": true, "types": ["node"], - "outDir": "./dist", "strict": true, "noEmit": true, - "noEmitOnError": true, "noFallthroughCasesInSwitch": true, "noImplicitAny": false, "noImplicitReturns": true, "noImplicitThis": true, "noUnusedParameters": true, "forceConsistentCasingInFileNames": true, - "esModuleInterop": true, - "declaration": true + "esModuleInterop": true } }