@salesforce/core
Version:
Core libraries to interact with SFDX projects, orgs, and APIs.
85 lines • 3.23 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReplacementsSchema = void 0;
/*
* Copyright 2026, Salesforce, 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.
*/
const zod_1 = require("zod");
const EnvConditionalSchema = zod_1.z
.object({
env: zod_1.z.string(),
value: zod_1.z.string(),
})
.strict();
const BaseReplacementSchema = zod_1.z.object({
replaceWhenEnv: zod_1.z.array(EnvConditionalSchema).optional(),
});
// Create explicit union variants to generate proper JSON Schema with anyOf
// Each variant has strict required fields and additionalProperties: false
exports.ReplacementsSchema = zod_1.z.union([
// filename + stringToReplace + replaceWithFile
BaseReplacementSchema.extend({
filename: zod_1.z.string(),
stringToReplace: zod_1.z.string(),
replaceWithFile: zod_1.z.string(),
}).strict(),
// filename + stringToReplace + replaceWithEnv
BaseReplacementSchema.extend({
filename: zod_1.z.string(),
stringToReplace: zod_1.z.string(),
replaceWithEnv: zod_1.z.string(),
allowUnsetEnvVariable: zod_1.z.boolean().optional(),
}).strict(),
// filename + regexToReplace + replaceWithFile
BaseReplacementSchema.extend({
filename: zod_1.z.string(),
regexToReplace: zod_1.z.string(),
replaceWithFile: zod_1.z.string(),
}).strict(),
// filename + regexToReplace + replaceWithEnv
BaseReplacementSchema.extend({
filename: zod_1.z.string(),
regexToReplace: zod_1.z.string(),
replaceWithEnv: zod_1.z.string(),
allowUnsetEnvVariable: zod_1.z.boolean().optional(),
}).strict(),
// glob + stringToReplace + replaceWithFile
BaseReplacementSchema.extend({
glob: zod_1.z.string(),
stringToReplace: zod_1.z.string(),
replaceWithFile: zod_1.z.string(),
}).strict(),
// glob + stringToReplace + replaceWithEnv
BaseReplacementSchema.extend({
glob: zod_1.z.string(),
stringToReplace: zod_1.z.string(),
replaceWithEnv: zod_1.z.string(),
allowUnsetEnvVariable: zod_1.z.boolean().optional(),
}).strict(),
// glob + regexToReplace + replaceWithFile
BaseReplacementSchema.extend({
glob: zod_1.z.string(),
regexToReplace: zod_1.z.string(),
replaceWithFile: zod_1.z.string(),
}).strict(),
// glob + regexToReplace + replaceWithEnv
BaseReplacementSchema.extend({
glob: zod_1.z.string(),
regexToReplace: zod_1.z.string(),
replaceWithEnv: zod_1.z.string(),
allowUnsetEnvVariable: zod_1.z.boolean().optional(),
}).strict(),
]);
//# sourceMappingURL=replacements.js.map