nitro-drizzle 0.2.1 → 0.2.3
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { relativeWithDot } from "./path.mjs";
|
|
2
2
|
import { writeFile } from "./fs.mjs";
|
|
3
|
-
import { join } from "pathe";
|
|
3
|
+
import { dirname, join, resolve } from "pathe";
|
|
4
4
|
//#region src/module/internal/types.ts
|
|
5
5
|
async function addAugmentations(nitroOptions, nitroTypes, augmentations) {
|
|
6
6
|
nitroTypes.tsConfig ||= {};
|
|
@@ -19,13 +19,16 @@ async function addDeclarations(nitroOptions, nitroTypes, declarations) {
|
|
|
19
19
|
function typesDir(nitroOptions) {
|
|
20
20
|
return join(nitroOptions.buildDir, "types");
|
|
21
21
|
}
|
|
22
|
+
function tsconfigDir(nitroOptions) {
|
|
23
|
+
return dirname(resolve(nitroOptions.buildDir, nitroOptions.typescript.tsconfigPath));
|
|
24
|
+
}
|
|
22
25
|
async function writeTypeFiles(nitroOptions, modules) {
|
|
23
26
|
const paths = [];
|
|
24
27
|
const dir = typesDir(nitroOptions);
|
|
25
28
|
for (const filename in modules) {
|
|
26
29
|
const typesFilename = join(dir, filename);
|
|
27
30
|
await writeFile(typesFilename, await getContent(modules[filename]));
|
|
28
|
-
const relativeFilename = relativeWithDot(
|
|
31
|
+
const relativeFilename = relativeWithDot(tsconfigDir(nitroOptions), typesFilename);
|
|
29
32
|
paths.push(relativeFilename);
|
|
30
33
|
}
|
|
31
34
|
return paths;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","names":[],"sources":["../../../src/module/internal/types.ts"],"sourcesContent":["import type { NitroOptions, NitroTypes, VirtualModule } from \"nitropack/types\";\nimport { join } from \"pathe\";\nimport { relativeWithDot } from \"./path\";\nimport { writeFile } from \"./fs\";\nimport type { VirtualModules } from \"nitro-drizzle/shared\";\n\nexport async function addAugmentations(\n nitroOptions: NitroOptions,\n nitroTypes: NitroTypes,\n augmentations: VirtualModules,\n) {\n nitroTypes.tsConfig ||= {};\n nitroTypes.tsConfig.include ||= [];\n const paths = await writeTypeFiles(nitroOptions, augmentations);\n nitroTypes.tsConfig.include.push(...paths);\n}\n\nexport async function addDeclarations(\n nitroOptions: NitroOptions,\n nitroTypes: NitroTypes,\n declarations: Record<string, VirtualModules>,\n) {\n nitroTypes.tsConfig ||= {};\n\n for (const alias in declarations) {\n nitroTypes.tsConfig.compilerOptions ||= {};\n nitroTypes.tsConfig.compilerOptions.paths ||= {};\n nitroTypes.tsConfig.compilerOptions.paths[alias] = await writeTypeFiles(\n nitroOptions,\n declarations[alias],\n );\n }\n}\n\nfunction typesDir(nitroOptions: NitroOptions) {\n return join(nitroOptions.buildDir, \"types\");\n}\n\nasync function writeTypeFiles(nitroOptions: NitroOptions, modules: VirtualModules) {\n const paths: string[] = [];\n const dir = typesDir(nitroOptions);\n for (const filename in modules) {\n const typesFilename = join(dir, filename);\n await writeFile(typesFilename, await getContent(modules[filename]));\n const relativeFilename = relativeWithDot(
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../../../src/module/internal/types.ts"],"sourcesContent":["import type { NitroOptions, NitroTypes, VirtualModule } from \"nitropack/types\";\nimport { dirname, join, resolve } from \"pathe\";\nimport { relativeWithDot } from \"./path\";\nimport { writeFile } from \"./fs\";\nimport type { VirtualModules } from \"nitro-drizzle/shared\";\n\nexport async function addAugmentations(\n nitroOptions: NitroOptions,\n nitroTypes: NitroTypes,\n augmentations: VirtualModules,\n) {\n nitroTypes.tsConfig ||= {};\n nitroTypes.tsConfig.include ||= [];\n const paths = await writeTypeFiles(nitroOptions, augmentations);\n nitroTypes.tsConfig.include.push(...paths);\n}\n\nexport async function addDeclarations(\n nitroOptions: NitroOptions,\n nitroTypes: NitroTypes,\n declarations: Record<string, VirtualModules>,\n) {\n nitroTypes.tsConfig ||= {};\n\n for (const alias in declarations) {\n nitroTypes.tsConfig.compilerOptions ||= {};\n nitroTypes.tsConfig.compilerOptions.paths ||= {};\n nitroTypes.tsConfig.compilerOptions.paths[alias] = await writeTypeFiles(\n nitroOptions,\n declarations[alias],\n );\n }\n}\n\nfunction typesDir(nitroOptions: NitroOptions) {\n return join(nitroOptions.buildDir, \"types\");\n}\n\nfunction tsconfigDir(nitroOptions: NitroOptions) {\n const tsConfigPath = resolve(\n nitroOptions.buildDir,\n nitroOptions.typescript.tsconfigPath\n );\n const tsconfigDir = dirname(tsConfigPath);\n return tsconfigDir\n}\n\nasync function writeTypeFiles(nitroOptions: NitroOptions, modules: VirtualModules) {\n const paths: string[] = [];\n const dir = typesDir(nitroOptions);\n for (const filename in modules) {\n const typesFilename = join(dir, filename);\n await writeFile(typesFilename, await getContent(modules[filename]));\n const relativeFilename = relativeWithDot(tsconfigDir(nitroOptions), typesFilename);\n paths.push(relativeFilename);\n }\n return paths;\n}\n\nasync function getContent(module: VirtualModule) {\n return \"string\" == typeof module ? module : await module();\n}\n"],"mappings":";;;;AAMA,eAAsB,iBACpB,cACA,YACA,eACA;CACA,WAAW,aAAa,CAAC;CACzB,WAAW,SAAS,YAAY,CAAC;CACjC,MAAM,QAAQ,MAAM,eAAe,cAAc,aAAa;CAC9D,WAAW,SAAS,QAAQ,KAAK,GAAG,KAAK;AAC3C;AAEA,eAAsB,gBACpB,cACA,YACA,cACA;CACA,WAAW,aAAa,CAAC;CAEzB,KAAK,MAAM,SAAS,cAAc;EAChC,WAAW,SAAS,oBAAoB,CAAC;EACzC,WAAW,SAAS,gBAAgB,UAAU,CAAC;EAC/C,WAAW,SAAS,gBAAgB,MAAM,SAAS,MAAM,eACvD,cACA,aAAa,MACf;CACF;AACF;AAEA,SAAS,SAAS,cAA4B;CAC5C,OAAO,KAAK,aAAa,UAAU,OAAO;AAC5C;AAEA,SAAS,YAAY,cAA4B;CAM/C,OADoB,QAJC,QACnB,aAAa,UACb,aAAa,WAAW,YAEa,CACtB;AACnB;AAEA,eAAe,eAAe,cAA4B,SAAyB;CACjF,MAAM,QAAkB,CAAC;CACzB,MAAM,MAAM,SAAS,YAAY;CACjC,KAAK,MAAM,YAAY,SAAS;EAC9B,MAAM,gBAAgB,KAAK,KAAK,QAAQ;EACxC,MAAM,UAAU,eAAe,MAAM,WAAW,QAAQ,SAAS,CAAC;EAClE,MAAM,mBAAmB,gBAAgB,YAAY,YAAY,GAAG,aAAa;EACjF,MAAM,KAAK,gBAAgB;CAC7B;CACA,OAAO;AACT;AAEA,eAAe,WAAW,QAAuB;CAC/C,OAAO,YAAY,OAAO,SAAS,SAAS,MAAM,OAAO;AAC3D"}
|