shiftapi 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -59,13 +59,12 @@ function indent(text, spaces = 2) {
|
|
|
59
59
|
const prefix = " ".repeat(spaces);
|
|
60
60
|
return text.split("\n").map((line) => line ? prefix + line : line).join("\n");
|
|
61
61
|
}
|
|
62
|
-
function dtsTemplate(generatedTypes
|
|
63
|
-
const src = openapiImport ?? "openapi-fetch";
|
|
62
|
+
function dtsTemplate(generatedTypes) {
|
|
64
63
|
return `// Auto-generated by shiftapi. Do not edit.
|
|
65
64
|
declare module "@shiftapi/client" {
|
|
66
65
|
${indent(generatedTypes)}
|
|
67
66
|
|
|
68
|
-
import type createClient from "
|
|
67
|
+
import type createClient from "openapi-fetch";
|
|
69
68
|
|
|
70
69
|
export const client: ReturnType<typeof createClient<paths>>;
|
|
71
70
|
export { createClient };
|
|
@@ -147,22 +146,18 @@ function writeGeneratedFiles(typesRoot, generatedDts, baseUrl, options) {
|
|
|
147
146
|
if (!existsSync(outDir)) {
|
|
148
147
|
mkdirSync(outDir, { recursive: true });
|
|
149
148
|
}
|
|
150
|
-
|
|
151
|
-
writeFileSync(resolve(outDir, "client.d.ts"), dtsTemplate(generatedDts, useLocalOpenapi ? "./openapi-fetch.js" : void 0));
|
|
149
|
+
writeFileSync(resolve(outDir, "client.d.ts"), dtsTemplate(generatedDts));
|
|
152
150
|
writeFileSync(resolve(outDir, "client.js"), options?.clientJsContent ?? clientJsTemplate(baseUrl));
|
|
153
151
|
if (options?.openapiSource) {
|
|
154
152
|
writeFileSync(resolve(outDir, "openapi-fetch.js"), options.openapiSource);
|
|
155
153
|
}
|
|
156
|
-
if (options?.openapiDts) {
|
|
157
|
-
writeFileSync(resolve(outDir, "openapi-fetch.d.ts"), options.openapiDts);
|
|
158
|
-
}
|
|
159
154
|
writeFileSync(
|
|
160
155
|
resolve(outDir, "tsconfig.json"),
|
|
161
156
|
JSON.stringify(
|
|
162
157
|
{
|
|
163
158
|
compilerOptions: {
|
|
164
159
|
paths: {
|
|
165
|
-
[MODULE_ID]: ["./client
|
|
160
|
+
[MODULE_ID]: ["./client"]
|
|
166
161
|
}
|
|
167
162
|
}
|
|
168
163
|
},
|
|
@@ -184,15 +179,15 @@ function patchTsConfigPaths(tsconfigDir, typesRoot) {
|
|
|
184
179
|
);
|
|
185
180
|
return;
|
|
186
181
|
}
|
|
187
|
-
const
|
|
188
|
-
const
|
|
182
|
+
const clientRel = relative(tsconfigDir, resolve(typesRoot, ".shiftapi", "client"));
|
|
183
|
+
const clientPath = clientRel.startsWith("..") ? clientRel : `./${clientRel}`;
|
|
189
184
|
tsconfig.compilerOptions = tsconfig.compilerOptions || {};
|
|
190
185
|
tsconfig.compilerOptions.paths = tsconfig.compilerOptions.paths || {};
|
|
191
186
|
const existing = tsconfig.compilerOptions.paths[MODULE_ID];
|
|
192
|
-
if (Array.isArray(existing) && existing.length === 1 && existing[0] ===
|
|
187
|
+
if (Array.isArray(existing) && existing.length === 1 && existing[0] === clientPath) {
|
|
193
188
|
return;
|
|
194
189
|
}
|
|
195
|
-
tsconfig.compilerOptions.paths[MODULE_ID] = [
|
|
190
|
+
tsconfig.compilerOptions.paths[MODULE_ID] = [clientPath];
|
|
196
191
|
const detectedIndent = raw.match(/^[ \t]+/m)?.[0] ?? " ";
|
|
197
192
|
writeFileSync(tsconfigPath, stringify(tsconfig, null, detectedIndent) + "\n");
|
|
198
193
|
console.log(
|
package/dist/internal.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ declare function regenerateTypes(serverEntry: string, goRoot: string, baseUrl: s
|
|
|
8
8
|
declare function writeGeneratedFiles(typesRoot: string, generatedDts: string, baseUrl: string, options?: {
|
|
9
9
|
clientJsContent?: string;
|
|
10
10
|
openapiSource?: string;
|
|
11
|
-
openapiDts?: string;
|
|
12
11
|
}): void;
|
|
13
12
|
declare function patchTsConfigPaths(tsconfigDir: string, typesRoot: string): void;
|
|
14
13
|
|
|
@@ -25,7 +24,7 @@ declare function extractSpec(serverEntry: string, goRoot: string): object;
|
|
|
25
24
|
*/
|
|
26
25
|
declare function generateTypes(spec: object): Promise<string>;
|
|
27
26
|
|
|
28
|
-
declare function dtsTemplate(generatedTypes: string
|
|
27
|
+
declare function dtsTemplate(generatedTypes: string): string;
|
|
29
28
|
declare function clientJsTemplate(baseUrl: string): string;
|
|
30
29
|
declare function nextClientJsTemplate(port: number, baseUrl: string, devApiPrefix?: string): string;
|
|
31
30
|
declare function virtualModuleTemplate(baseUrl: string, devApiPrefix?: string): string;
|
package/dist/internal.js
CHANGED
package/dist/prepare.js
CHANGED
package/package.json
CHANGED