qwen-code/scripts/flyway-migration-utils.js
jinye 28415ddff3
refactor(managed-agent): Consolidate server and broker sources (#14277)
* refactor(managed-agent): Consolidate server and broker sources

Move the combined Java application beside sdk-java and remove the standalone Runtime Broker artifact. Update build, development, packaging and CI references while preserving Java package identities, runtime protocols and schema resources.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* docs(managed-agent): Preserve historical evidence and verification guidance

Restore commit-pinned H3 probe inputs and align the Java verification environment contract with the consolidated server layout.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(ci): Run hosted Broker tests under Bash

Keep Maven property arguments intact on Windows and stop before Broker tests when the SDK install fails. Exercise both successful and failed SDK installation in the workflow regression tests.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(ci): Quote the hosted Broker shell value

Follow the repository yamllint single-quote rule without changing the parsed workflow configuration.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-10-16 00:28:58 +00:00

60 lines
2.4 KiB
JavaScript

/**
* @license
* Copyright 2026 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/
// Flyway's naming rules for managed-agent-server's hand-allocated versions,
// shared by check-flyway-migrations.js (one checkout) and
// check-flyway-open-prs.js (open pull requests against main).
import { existsSync, readdirSync } from 'node:fs';
import path from 'node:path';
// Registered locations cover the legacy upgrades and the fresh managed-schema
// baseline in Managed Agent Server; versions are checked across dependencies.
// Flyway scans each location AND its subdirectories, and nowhere else — a
// versioned-migration file anywhere
// else under the source root is invisible to it, so finding one there means
// the location moved and check-flyway-migrations.js must say so instead of
// passing on what is left. Its probes derive the db roots and source roots
// from this table, so editing it cannot silently blind them.
export const LOCATIONS = [
{ dir: ['src', 'main', 'resources', 'db', 'migration'], suffix: '.sql' },
{ dir: ['src', 'main', 'java', 'db', 'migration'], suffix: '.java' },
{ dir: ['src', 'main', 'resources', 'db', 'managed-schema'], suffix: '.sql' },
];
// A versioned migration is V<version>__<description>; the version is numeric
// segments joined by dots or underscores.
const MIGRATION_NAME = /^V(\d+(?:[._]\d+)*)__/;
// Flyway compares versions numerically segment by segment, so V016 collides
// with V16 and a trailing .0 segment carries no meaning.
const normalize = (version) =>
version
.split(/[._]/)
.map((segment) => segment.replace(/^0+(?=\d)/, ''))
.join('.')
.replace(/(\.0)*$/, '');
export const migrationVersion = (name) =>
normalize(MIGRATION_NAME.exec(name)[1]);
// Flyway matches the suffix case-insensitively — V1__b.SQL claims version 1
// exactly like V1__a.sql does.
export const isMigrationFile = (name, suffix) =>
name.toLowerCase().endsWith(suffix) && MIGRATION_NAME.test(name);
// Not readdirSync's `recursive`: a Node older than 18.17 ignores it (see
// check-failsafe-reports.js). Flyway scans a location's subdirectories too.
export const migrationFiles = (dir, suffix) => {
if (!existsSync(dir)) return [];
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) =>
entry.isDirectory()
? migrationFiles(path.join(dir, entry.name), suffix)
: isMigrationFile(entry.name, suffix)
? [path.join(dir, entry.name)]
: [],
);
};