-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathremoveInternalOas.ts
More file actions
44 lines (38 loc) · 1.4 KB
/
removeInternalOas.ts
File metadata and controls
44 lines (38 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (c) 2025, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import path from "path";
import fs from "fs-extra";
import { PRODUCTION_API_PATH } from "./lib/config";
/**
* Recursively removes all files ending in '-internal.yaml' from a directory and its subdirectories
* @param directoryPath - The path to the directory to process
*/
export function removeInternalOas(directoryPath: string): void {
if (!fs.existsSync(directoryPath)) {
console.warn(`Directory does not exist: ${directoryPath}`);
return;
}
const items = fs.readdirSync(directoryPath);
items.forEach((item) => {
const fullPath = path.join(directoryPath, item);
const stat = fs.statSync(fullPath);
if (stat.isDirectory()) {
// Recursively process subdirectories
removeInternalOas(fullPath);
} else if (stat.isFile() && item.endsWith("-internal.yaml")) {
// Remove internal files
fs.removeSync(fullPath);
console.log(`Removed internal file: ${fullPath}`);
}
});
}
// Run the function if this file is executed directly
if (require.main === module) {
console.log(`Removing internal OAS files from: ${PRODUCTION_API_PATH}`);
removeInternalOas(PRODUCTION_API_PATH);
console.log("Internal OAS files removal completed.");
}