Notably, this gets us `@actions/github` 6.0.1, which is necessary for `github.context.runAttempt` (so I have also updated `package.json` accordingly). On that note... great job following semver, GitHub! Between this and the non-breaking major version change on `@actions/cache`, I'm starting to feel like nobody on the Actions team understands how software versioning works.
46 lines
1.6 KiB
JavaScript
46 lines
1.6 KiB
JavaScript
// Copyright 2021-2025 Buf Technologies, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
import { createImportSymbol } from "./import-symbol.js";
|
|
import { symbols } from "@bufbuild/protobuf/codegenv2";
|
|
export function createRuntimeImports(bootstrapWkt) {
|
|
return mapRecord(symbols, bootstrapWkt);
|
|
}
|
|
function mapRecord(record, bootstrapWkt) {
|
|
const result = Object.create(null);
|
|
for (const [key, value] of Object.entries(record)) {
|
|
if (isSymbolInfo(value)) {
|
|
result[key] = createImportSymbol(key, bootstrapWkt ? value.bootstrapWktFrom : value.from, value.typeOnly);
|
|
}
|
|
else {
|
|
result[key] = mapRecord(record[key], bootstrapWkt);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function isSymbolInfo(arg) {
|
|
if (typeof arg != "object" || arg === null) {
|
|
return false;
|
|
}
|
|
const wantNames = [
|
|
"typeOnly",
|
|
"from",
|
|
"bootstrapWktFrom",
|
|
];
|
|
const gotNames = Object.getOwnPropertyNames(arg);
|
|
if (gotNames.length !== wantNames.length) {
|
|
return false;
|
|
}
|
|
return wantNames.every((w) => gotNames.includes(w));
|
|
}
|