Skip to content

Commit e2ac356

Browse files
committed
fix updateApis command
1 parent 0c2474a commit e2ac356

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"clean": "rm -rf renderedTemplates dist",
2525
"compile": "tsc && eslint dist --ext .ts,.js --quiet --fix",
2626
"depcheck": "depcheck",
27-
"diffApis": "raml-toolkit diff --dir updateApisTmp/oldApis apis -f console -o updateApisTmp/oasDiff.txt -s oas",
27+
"diffApis": "raml-toolkit diff --dir updateApisTmp/oldApis apis -f console -o updateApisTmp/oasDiff.txt -s oas --normalize-directory-names",
2828
"doc": "npm run doc:generate && npm run doc:resources",
2929
"doc:generate": "typedoc --mode modules --out ./docs renderedTemplates/** --tsconfig tsconfig.json --external-modulemap \".*/renderedTemplates/([\\w]+)\" --exclude \"renderedTemplates/index.ts\"",
3030
"doc:resources": "cp CHANGELOG.md ./docs",
@@ -33,11 +33,12 @@
3333
"prepack": "npm run build",
3434
"prepare": "snyk protect",
3535
"renderTemplates": "PACKAGE_VERSION=$(node -p \"require('./package.json').version\") ts-node src/generate-oas.ts",
36+
"removeInternalOas": "ts-node src/removeInternalOas.ts",
3637
"snyk:auth": "snyk auth",
3738
"pretest": "npm run lint && npm run depcheck",
3839
"test": "nyc mocha \"src/**/*.test.ts\"",
3940
"test:ci": "npm test -- --reporter=xunit --reporter-options output=./reports/generator.xml",
40-
"updateApis": "npm run backupApis && ts-node src/updateApis.ts && npm run diffApis"
41+
"updateApis": "npm run removeInternalOas && npm run backupApis && ts-node src/updateApis.ts && npm run removeInternalOas && npm run diffApis"
4142
},
4243
"mocha": {
4344
"file": [

src/lib/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const API_FAMILIES = [
3434
"shopper-experience-oas",
3535
"shopper-login-oas",
3636
"shopper-stores-oas",
37+
"shopper-consents-oas",
3738
];
3839

3940
export const PRODUCTION_API_PATH = `${__dirname}/../../apis`;

src/removeInternalOas.ts

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

0 commit comments

Comments
 (0)