-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathgenerate.ts
More file actions
31 lines (24 loc) · 1.03 KB
/
generate.ts
File metadata and controls
31 lines (24 loc) · 1.03 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
/*
* Copyright (c) 2020, 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 { generate } from "@commerce-apps/raml-toolkit";
import { registerHelpers, registerPartials, setupApis } from "./lib/utils";
import { copySync } from "fs-extra";
const API_DIRECTORY = path.resolve(
process.env.COMMERCE_SDK_INPUT_DIR || `${__dirname}/../apis`
);
const OUTPUT_DIRECTORY = path.join(__dirname, "../renderedTemplates/helpers");
const HELPERS_DIRECTORY = path.join(__dirname, "../src/static/helpers");
registerHelpers();
registerPartials();
console.log(`Creating SDK for ${API_DIRECTORY}`);
const skipTestFiles = (src: string): boolean => !/\.test\.[a-z]+$/.test(src);
copySync(HELPERS_DIRECTORY, OUTPUT_DIRECTORY, { filter: skipTestFiles });
setupApis(
API_DIRECTORY,
path.resolve(`${__dirname}/../renderedTemplates`)
).then((apis: generate.ApiMetadata) => apis.render());