({
header,
outputPath,
plugin,
project,
}: {
header?: OutputHeader;
outputPath: string;
plugin: DefinePlugin<Client.Config & { name: string }>['Config'];
project: IProject;
})
| 143 | * Creates a `client` folder containing the same modules as the client package. |
| 144 | */ |
| 145 | export function generateClientBundle({ |
| 146 | header, |
| 147 | outputPath, |
| 148 | plugin, |
| 149 | project, |
| 150 | }: { |
| 151 | header?: OutputHeader; |
| 152 | outputPath: string; |
| 153 | plugin: DefinePlugin<Client.Config & { name: string }>['Config']; |
| 154 | project: IProject; |
| 155 | }): Map<string, string> | undefined { |
| 156 | const renamed = new Map<string, string>(); |
| 157 | const headerPrefix = outputHeaderToPrefix({ |
| 158 | defaultValue: ['# This file is auto-generated by @hey-api/openapi-python'], |
| 159 | header, |
| 160 | project, |
| 161 | }); |
| 162 | |
| 163 | // copy Hey API clients to output |
| 164 | const isHeyApiClientPlugin = plugin.name.startsWith('@hey-api/client-'); |
| 165 | if (isHeyApiClientPlugin) { |
| 166 | const { clientPath } = getClientBundlePaths(plugin.name); |
| 167 | // const { clientPath, corePath } = getClientBundlePaths(plugin.name); |
| 168 | |
| 169 | // copy client core |
| 170 | // const coreOutputPath = path.resolve(outputPath, 'core'); |
| 171 | // ensureDirSync(coreOutputPath); |
| 172 | // copyRecursivePnP(corePath, coreOutputPath); |
| 173 | |
| 174 | // copy client bundle |
| 175 | const clientOutputPath = path.resolve(outputPath, 'client'); |
| 176 | ensureDirSync(clientOutputPath); |
| 177 | copyRecursivePnP(clientPath, clientOutputPath); |
| 178 | |
| 179 | if (project) { |
| 180 | // const copiedCoreFiles = fs.readdirSync(coreOutputPath); |
| 181 | // for (const file of copiedCoreFiles) { |
| 182 | // renameFile({ |
| 183 | // filePath: path.resolve(coreOutputPath, file), |
| 184 | // project, |
| 185 | // renamed, |
| 186 | // }); |
| 187 | // } |
| 188 | |
| 189 | const copiedClientFiles = fs.readdirSync(clientOutputPath); |
| 190 | for (const file of copiedClientFiles) { |
| 191 | renameFile({ |
| 192 | filePath: path.resolve(clientOutputPath, file), |
| 193 | project, |
| 194 | renamed, |
| 195 | }); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | // const coreFiles = fs.readdirSync(coreOutputPath); |
| 200 | // for (const file of coreFiles) { |
| 201 | // replaceImports({ |
| 202 | // filePath: path.resolve(coreOutputPath, file), |
no test coverage detected