@geekmidas/cli 0.0.9 → 0.0.11
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.
- package/README.md +33 -0
- package/dist/{build-DGJAXiy_.cjs → build-C-UDqpkV.cjs} +15 -19
- package/dist/{build-CE77jmn4.mjs → build-DCAjSjA0.mjs} +16 -20
- package/dist/build.cjs +2 -4
- package/dist/build.mjs +2 -4
- package/dist/{cli-CTfdNl5c.mjs → cli-DPcRbYh5.mjs} +43 -3
- package/dist/{cli-aXPCpkGS.cjs → cli-NvCqdZtD.cjs} +43 -3
- package/dist/cli.cjs +4 -6
- package/dist/cli.mjs +4 -6
- package/dist/config-D8AyiwBU.cjs +23 -0
- package/dist/config-DV1Lwdkx.mjs +17 -0
- package/dist/config.cjs +1 -1
- package/dist/config.mjs +1 -1
- package/dist/index.cjs +4 -6
- package/dist/index.mjs +4 -6
- package/dist/{openapi-C84tyelp.cjs → openapi-BX7ba0w0.cjs} +1 -1
- package/dist/{openapi-UIMy3Lzi.mjs → openapi-BxI6zE0N.mjs} +1 -1
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.mjs +2 -2
- package/package.json +3 -4
- package/src/build.ts +10 -46
- package/src/cli.ts +2 -1
- package/src/config.ts +5 -27
- package/src/types.ts +0 -1
- package/dist/config-D-b45V57.cjs +0 -41
- package/dist/config-Nd751N3o.mjs +0 -35
- package/dist/helpers/pathResolver.cjs +0 -6
- package/dist/helpers/pathResolver.mjs +0 -4
- package/dist/pathResolver-B6y4yoWk.cjs +0 -47
- package/dist/pathResolver-DaMnbf26.mjs +0 -29
- package/dist/tsconfig-83amrDAp.cjs +0 -94
- package/dist/tsconfig-BtO228Cz.mjs +0 -70
- package/dist/tsconfig.cjs +0 -6
- package/dist/tsconfig.mjs +0 -3
- package/src/helpers/pathResolver.ts +0 -46
- package/src/tsconfig.ts +0 -132
package/src/tsconfig.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
import { existsSync } from 'fs';
|
|
3
|
-
import { join, dirname, resolve } from 'path';
|
|
4
|
-
|
|
5
|
-
export interface TsConfigResult {
|
|
6
|
-
configPath: string;
|
|
7
|
-
config: ts.ParsedCommandLine;
|
|
8
|
-
compilerOptions: ts.CompilerOptions;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Find and parse the nearest tsconfig.json file
|
|
13
|
-
*/
|
|
14
|
-
export function loadTsConfig(
|
|
15
|
-
searchPath: string = process.cwd(),
|
|
16
|
-
): TsConfigResult | null {
|
|
17
|
-
const configPath = ts.findConfigFile(searchPath, existsSync);
|
|
18
|
-
|
|
19
|
-
if (!configPath) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
24
|
-
|
|
25
|
-
if (configFile.error) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`Error reading tsconfig.json: ${ts.flattenDiagnosticMessageText(configFile.error.messageText, '\n')}`,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const parsedConfig = ts.parseJsonConfigFileContent(
|
|
32
|
-
configFile.config,
|
|
33
|
-
ts.sys,
|
|
34
|
-
dirname(configPath),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
if (parsedConfig.errors.length > 0) {
|
|
38
|
-
const errors = parsedConfig.errors
|
|
39
|
-
.map((error) => ts.flattenDiagnosticMessageText(error.messageText, '\n'))
|
|
40
|
-
.join('\n');
|
|
41
|
-
throw new Error(`Error parsing tsconfig.json: ${errors}`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
configPath,
|
|
46
|
-
config: parsedConfig,
|
|
47
|
-
compilerOptions: parsedConfig.options,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Resolve a module path using TypeScript's module resolution
|
|
53
|
-
*/
|
|
54
|
-
export function resolveModulePath(
|
|
55
|
-
moduleName: string,
|
|
56
|
-
containingFile: string,
|
|
57
|
-
tsConfig?: TsConfigResult,
|
|
58
|
-
): string | null {
|
|
59
|
-
const compilerOptions = tsConfig?.compilerOptions || {};
|
|
60
|
-
|
|
61
|
-
const result = ts.resolveModuleName(
|
|
62
|
-
moduleName,
|
|
63
|
-
containingFile,
|
|
64
|
-
compilerOptions,
|
|
65
|
-
ts.sys,
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
if (result.resolvedModule) {
|
|
69
|
-
return result.resolvedModule.resolvedFileName;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Get the output path for a TypeScript file based on tsconfig
|
|
77
|
-
*/
|
|
78
|
-
export function getOutputPath(
|
|
79
|
-
filePath: string,
|
|
80
|
-
tsConfig?: TsConfigResult,
|
|
81
|
-
): string {
|
|
82
|
-
if (!tsConfig) {
|
|
83
|
-
// Default: replace .ts with .js
|
|
84
|
-
return filePath.replace(/\.ts$/, '.js');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const { compilerOptions, configPath } = tsConfig;
|
|
88
|
-
const configDir = dirname(configPath);
|
|
89
|
-
|
|
90
|
-
// Handle outDir option
|
|
91
|
-
if (compilerOptions.outDir) {
|
|
92
|
-
const rootDir = compilerOptions.rootDir || configDir;
|
|
93
|
-
const relativePath = filePath.startsWith(rootDir)
|
|
94
|
-
? filePath.slice(rootDir.length)
|
|
95
|
-
: filePath;
|
|
96
|
-
|
|
97
|
-
const outputPath = join(compilerOptions.outDir, relativePath);
|
|
98
|
-
return outputPath.replace(/\.ts$/, '.js');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Default: in-place compilation
|
|
102
|
-
return filePath.replace(/\.ts$/, '.js');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Apply path mappings from tsconfig paths
|
|
107
|
-
*/
|
|
108
|
-
export function resolvePathMapping(
|
|
109
|
-
importPath: string,
|
|
110
|
-
tsConfig?: TsConfigResult,
|
|
111
|
-
): string {
|
|
112
|
-
if (!tsConfig || !tsConfig.compilerOptions.paths) {
|
|
113
|
-
return importPath;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const { paths, baseUrl } = tsConfig.compilerOptions;
|
|
117
|
-
const configDir = dirname(tsConfig.configPath);
|
|
118
|
-
const resolvedBaseUrl = baseUrl ? resolve(configDir, baseUrl) : configDir;
|
|
119
|
-
|
|
120
|
-
for (const [pattern, replacements] of Object.entries(paths)) {
|
|
121
|
-
const regex = new RegExp('^' + pattern.replace('*', '(.*)') + '$');
|
|
122
|
-
const match = importPath.match(regex);
|
|
123
|
-
|
|
124
|
-
if (match && replacements.length > 0) {
|
|
125
|
-
const replacement = replacements[0];
|
|
126
|
-
const resolvedPath = replacement.replace('*', match[1] || '');
|
|
127
|
-
return resolve(resolvedBaseUrl, resolvedPath);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return importPath;
|
|
132
|
-
}
|