• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7* http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15
16import * as fs from 'fs';
17import { GenInfo, HdfRootInfo, ServiceRootInfo } from "../datatype";
18import { replaceAll } from '../../common/tool';
19
20// 生成sa非特殊处理的文件, 如xxx.cfg
21export function genSaCommonFile(rootInfo: ServiceRootInfo, filePath: string, fileContent: string) {
22  fileContent = replaceAll(fileContent, '[serviceName]', rootInfo.serviceName);
23  fileContent = replaceAll(fileContent, '[marcoName]', rootInfo.serviceName.toUpperCase());
24  fileContent = replaceAll(fileContent, '[lowServiceName]', rootInfo.serviceName.toLowerCase());
25  fileContent = replaceAll(fileContent, '[serviceId]', rootInfo.serviceId);
26  fs.writeFileSync(filePath, fileContent);
27}
28
29// 生成hdf非特殊处理的文件, 如xxx.hcs
30export function genHdfCommonFile(rootInfo: HdfRootInfo, filePath: string, fileContent: string) {
31  let upperName = rootInfo.driverName.substring(0, 1).toLocaleUpperCase();
32  let marcoName = upperName + rootInfo.driverName.substring(1, rootInfo.driverName.length);
33  let upperDriverName = rootInfo.driverName.toLocaleUpperCase();
34  fileContent = replaceAll(fileContent, '[driverName]', rootInfo.driverName);
35  fileContent = replaceAll(fileContent, '[marcoName]', marcoName);
36  fileContent = replaceAll(fileContent, '[driverUpperName]', upperDriverName);
37  fs.writeFileSync(filePath, fileContent);
38}
39
40// 生成napi非特殊处理的文件
41export function genNapiCommonFile(rootInfo: GenInfo, filePath: string,
42  fileContent: string) {
43  fs.writeFileSync(filePath, fileContent);
44}
45
46