@graphitation/supermassive 1.1.6 → 2.0.0
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/.eslintcache +1 -1
- package/CHANGELOG.md +18 -2
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -2
- package/lib/index.mjs +0 -2
- package/package.json +11 -19
- package/bin/supermassive.js +0 -5
- package/lib/bin/supermassive.d.ts +0 -3
- package/lib/bin/supermassive.d.ts.map +0 -1
- package/lib/bin/supermassive.js +0 -133
- package/lib/bin/supermassive.mjs +0 -113
- package/lib/codegen/context/expect.d.ts +0 -1
- package/lib/codegen/context/expect.d.ts.map +0 -1
- package/lib/codegen/context/expect.js +0 -0
- package/lib/codegen/context/expect.mjs +0 -0
- package/lib/codegen/context/import.d.ts +0 -5
- package/lib/codegen/context/import.d.ts.map +0 -1
- package/lib/codegen/context/import.js +0 -55
- package/lib/codegen/context/import.mjs +0 -37
- package/lib/codegen/context/index.d.ts +0 -52
- package/lib/codegen/context/index.d.ts.map +0 -1
- package/lib/codegen/context/index.js +0 -253
- package/lib/codegen/context/index.mjs +0 -242
- package/lib/codegen/context/model.d.ts +0 -5
- package/lib/codegen/context/model.d.ts.map +0 -1
- package/lib/codegen/context/model.js +0 -53
- package/lib/codegen/context/model.mjs +0 -37
- package/lib/codegen/context/utilities.d.ts +0 -2
- package/lib/codegen/context/utilities.d.ts.map +0 -1
- package/lib/codegen/context/utilities.js +0 -26
- package/lib/codegen/context/utilities.mjs +0 -8
- package/lib/codegen/index.d.ts +0 -7
- package/lib/codegen/index.d.ts.map +0 -1
- package/lib/codegen/index.js +0 -41
- package/lib/codegen/index.mjs +0 -23
- package/lib/codegen/models.d.ts +0 -5
- package/lib/codegen/models.d.ts.map +0 -1
- package/lib/codegen/models.js +0 -159
- package/lib/codegen/models.mjs +0 -142
- package/lib/codegen/resolvers.d.ts +0 -5
- package/lib/codegen/resolvers.d.ts.map +0 -1
- package/lib/codegen/resolvers.js +0 -157
- package/lib/codegen/resolvers.mjs +0 -144
- package/lib/codegen/typedVisitor.d.ts +0 -57
- package/lib/codegen/typedVisitor.d.ts.map +0 -1
- package/lib/codegen/typedVisitor.js +0 -26
- package/lib/codegen/typedVisitor.mjs +0 -8
- package/lib/codegen/types.d.ts +0 -18
- package/lib/codegen/types.d.ts.map +0 -1
- package/lib/codegen/types.js +0 -15
- package/lib/codegen/types.mjs +0 -0
- package/lib/codegen/utilities.d.ts +0 -50
- package/lib/codegen/utilities.d.ts.map +0 -1
- package/lib/codegen/utilities.js +0 -193
- package/lib/codegen/utilities.mjs +0 -175
- package/lib/extractors/extractImplicitTypesToTypescript.d.ts +0 -4
- package/lib/extractors/extractImplicitTypesToTypescript.d.ts.map +0 -1
- package/lib/extractors/extractImplicitTypesToTypescript.js +0 -217
- package/lib/extractors/extractImplicitTypesToTypescript.mjs +0 -198
- package/lib/extractors/index.d.ts +0 -2
- package/lib/extractors/index.d.ts.map +0 -1
- package/lib/extractors/index.js +0 -23
- package/lib/extractors/index.mjs +0 -5
- package/lib/transforms/transformerTestUtils.d.ts +0 -79
- package/lib/transforms/transformerTestUtils.d.ts.map +0 -1
- package/lib/transforms/transformerTestUtils.js +0 -174
- package/lib/transforms/transformerTestUtils.mjs +0 -156
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
// src/extractors/extractImplicitTypesToTypescript.ts
|
|
2
|
-
import ts, { factory } from "typescript";
|
|
3
|
-
import {
|
|
4
|
-
Kind
|
|
5
|
-
} from "graphql";
|
|
6
|
-
var SPECIFIED_SCALARS = {
|
|
7
|
-
ID: "GraphQLID",
|
|
8
|
-
String: "GraphQLString",
|
|
9
|
-
Int: "GraphQLInt",
|
|
10
|
-
Float: "GraphQLFloat",
|
|
11
|
-
Boolean: "GraphQLBoolean"
|
|
12
|
-
};
|
|
13
|
-
var SUPERMASSIVE_TYPES = {
|
|
14
|
-
INTERFACE_TYPE_RESOLVER: "InterfaceTypeResolver",
|
|
15
|
-
UNION_TYPE_RESOLVER: "UnionTypeResolver",
|
|
16
|
-
OBJECT_TYPE_RESOLVER: "ObjectTypeResolver",
|
|
17
|
-
ENUM_TYPE_RESOLVER: "EnumTypeResolver",
|
|
18
|
-
SCALAR_TYPE_RESOLVER: "ScalarTypeResolver",
|
|
19
|
-
INPUT_OBJECT_TYPE_RESOLVER: "InputObjectTypeResolver"
|
|
20
|
-
};
|
|
21
|
-
function extractImplicitTypesToTypescript(document) {
|
|
22
|
-
var _a, _b;
|
|
23
|
-
const definitions = [];
|
|
24
|
-
const graphQLImports = [
|
|
25
|
-
"GraphQLList",
|
|
26
|
-
"GraphQLNonNull",
|
|
27
|
-
"GraphQLID",
|
|
28
|
-
"GraphQLString",
|
|
29
|
-
"GraphQLInt",
|
|
30
|
-
"GraphQLFloat",
|
|
31
|
-
"GraphQLBoolean"
|
|
32
|
-
];
|
|
33
|
-
const supermassiveImports = ["Resolvers"];
|
|
34
|
-
const identifiers = [];
|
|
35
|
-
const implementedBy = {};
|
|
36
|
-
const interfaceAstNodes = [];
|
|
37
|
-
for (let astNode of document.definitions) {
|
|
38
|
-
if (astNode.kind === Kind.SCALAR_TYPE_DEFINITION) {
|
|
39
|
-
definitions.push(createScalarType(astNode));
|
|
40
|
-
addToSetArray(graphQLImports, "GraphQLScalarType");
|
|
41
|
-
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.SCALAR_TYPE_RESOLVER);
|
|
42
|
-
addToSetArray(identifiers, astNode.name.value);
|
|
43
|
-
} else if (astNode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
44
|
-
definitions.push(createInputObjectType(astNode));
|
|
45
|
-
addToSetArray(graphQLImports, "GraphQLInputObjectType");
|
|
46
|
-
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.INPUT_OBJECT_TYPE_RESOLVER);
|
|
47
|
-
addToSetArray(identifiers, astNode.name.value);
|
|
48
|
-
} else if (astNode.kind === Kind.ENUM_TYPE_DEFINITION) {
|
|
49
|
-
definitions.push(createEnumType(astNode));
|
|
50
|
-
addToSetArray(graphQLImports, "GraphQLEnumType");
|
|
51
|
-
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.ENUM_TYPE_RESOLVER);
|
|
52
|
-
addToSetArray(identifiers, astNode.name.value);
|
|
53
|
-
} else if (astNode.kind === Kind.INTERFACE_TYPE_DEFINITION) {
|
|
54
|
-
interfaceAstNodes.push(astNode);
|
|
55
|
-
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.INTERFACE_TYPE_RESOLVER);
|
|
56
|
-
addToSetArray(identifiers, astNode.name.value);
|
|
57
|
-
} else if (astNode.kind === Kind.UNION_TYPE_DEFINITION) {
|
|
58
|
-
const types = (_a = astNode.types) == null ? void 0 : _a.map((typeNode) => {
|
|
59
|
-
return typeNode.name.value;
|
|
60
|
-
});
|
|
61
|
-
definitions.push(createUnionType(astNode, types || []));
|
|
62
|
-
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.UNION_TYPE_RESOLVER);
|
|
63
|
-
addToSetArray(identifiers, astNode.name.value);
|
|
64
|
-
} else if (astNode.kind === Kind.OBJECT_TYPE_DEFINITION) {
|
|
65
|
-
(_b = astNode.interfaces) == null ? void 0 : _b.forEach((node) => {
|
|
66
|
-
if (!implementedBy[node.name.value]) {
|
|
67
|
-
implementedBy[node.name.value] = [];
|
|
68
|
-
}
|
|
69
|
-
implementedBy[node.name.value].push(astNode.name.value);
|
|
70
|
-
});
|
|
71
|
-
definitions.push(createObjectType(astNode));
|
|
72
|
-
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.OBJECT_TYPE_RESOLVER);
|
|
73
|
-
addToSetArray(identifiers, astNode.name.value);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
interfaceAstNodes.forEach((astNode) => {
|
|
77
|
-
if (!implementedBy[astNode.name.value]) {
|
|
78
|
-
implementedBy[astNode.name.value] = [];
|
|
79
|
-
}
|
|
80
|
-
definitions.push(createInterfaceType(astNode, implementedBy[astNode.name.value]));
|
|
81
|
-
});
|
|
82
|
-
const graphQLImportDefinition = factory.createImportDeclaration(void 0, void 0, factory.createImportClause(false, void 0, factory.createNamedImports(graphQLImports.map((imp) => factory.createImportSpecifier(void 0, factory.createIdentifier(imp))))), factory.createStringLiteral("graphql"));
|
|
83
|
-
const supermassiveImportDefinition = factory.createImportDeclaration(void 0, void 0, factory.createImportClause(false, void 0, factory.createNamedImports(supermassiveImports.map((imp) => factory.createImportSpecifier(void 0, factory.createIdentifier(imp))))), factory.createStringLiteral("@graphitation/supermassive"));
|
|
84
|
-
const exportDefinition = factory.createVariableStatement([factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createVariableDeclarationList([
|
|
85
|
-
factory.createVariableDeclaration(factory.createIdentifier("resolvers"), void 0, factory.createTypeReferenceNode(factory.createIdentifier("Resolvers"), void 0), factory.createObjectLiteralExpression(identifiers.map((def) => factory.createShorthandPropertyAssignment(factory.createIdentifier(def), void 0))))
|
|
86
|
-
], ts.NodeFlags.Const));
|
|
87
|
-
return factory.createSourceFile([
|
|
88
|
-
graphQLImportDefinition,
|
|
89
|
-
supermassiveImportDefinition,
|
|
90
|
-
...definitions,
|
|
91
|
-
exportDefinition
|
|
92
|
-
], factory.createToken(ts.SyntaxKind.EndOfFileToken), 0);
|
|
93
|
-
}
|
|
94
|
-
function createDeclaration(name, decl, typeReferenceNode) {
|
|
95
|
-
return factory.createVariableStatement(void 0, factory.createVariableDeclarationList([
|
|
96
|
-
factory.createVariableDeclaration(factory.createIdentifier(name), void 0, typeReferenceNode, decl)
|
|
97
|
-
], ts.NodeFlags.Const));
|
|
98
|
-
}
|
|
99
|
-
function createScalarType(astNode) {
|
|
100
|
-
var _a;
|
|
101
|
-
return createDeclaration(astNode.name.value, factory.createNewExpression(factory.createIdentifier("GraphQLScalarType"), void 0, [
|
|
102
|
-
factory.createObjectLiteralExpression([
|
|
103
|
-
factory.createPropertyAssignment(factory.createIdentifier("name"), factory.createStringLiteral(astNode.name.value)),
|
|
104
|
-
factory.createPropertyAssignment(factory.createIdentifier("description"), factory.createStringLiteral(((_a = astNode.description) == null ? void 0 : _a.value) || ""))
|
|
105
|
-
], true)
|
|
106
|
-
]), factory.createTypeReferenceNode(factory.createIdentifier(SUPERMASSIVE_TYPES.SCALAR_TYPE_RESOLVER), void 0));
|
|
107
|
-
}
|
|
108
|
-
function createInputObjectType(astNode) {
|
|
109
|
-
var _a;
|
|
110
|
-
return createDeclaration(astNode.name.value, factory.createNewExpression(factory.createIdentifier("GraphQLInputObjectType"), void 0, [
|
|
111
|
-
factory.createObjectLiteralExpression([
|
|
112
|
-
factory.createPropertyAssignment(factory.createIdentifier("name"), factory.createStringLiteral(astNode.name.value)),
|
|
113
|
-
factory.createPropertyAssignment(factory.createIdentifier("description"), factory.createStringLiteral(((_a = astNode.description) == null ? void 0 : _a.value) || "")),
|
|
114
|
-
factory.createPropertyAssignment(factory.createIdentifier("fields"), factory.createArrowFunction(void 0, void 0, [], void 0, factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), factory.createParenthesizedExpression(factory.createObjectLiteralExpression(createInputFields(astNode.fields || []), true))))
|
|
115
|
-
], true)
|
|
116
|
-
]), factory.createTypeReferenceNode(factory.createIdentifier(SUPERMASSIVE_TYPES.INPUT_OBJECT_TYPE_RESOLVER), void 0));
|
|
117
|
-
}
|
|
118
|
-
function createInputFields(astNodes) {
|
|
119
|
-
return astNodes.map((astNode) => {
|
|
120
|
-
var _a;
|
|
121
|
-
const fields = [
|
|
122
|
-
factory.createPropertyAssignment(factory.createIdentifier("type"), createType(astNode.type)),
|
|
123
|
-
factory.createPropertyAssignment(factory.createIdentifier("description"), factory.createStringLiteral(((_a = astNode.description) == null ? void 0 : _a.value) || ""))
|
|
124
|
-
];
|
|
125
|
-
if (astNode.defaultValue) {
|
|
126
|
-
fields.push(factory.createPropertyAssignment(factory.createIdentifier("defaultValue"), createValue(astNode.defaultValue)));
|
|
127
|
-
}
|
|
128
|
-
return factory.createPropertyAssignment(factory.createIdentifier(astNode.name.value), factory.createObjectLiteralExpression(fields, true));
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function createEnumType(astNode) {
|
|
132
|
-
var _a;
|
|
133
|
-
return createDeclaration(astNode.name.value, factory.createNewExpression(factory.createIdentifier("GraphQLEnumType"), void 0, [
|
|
134
|
-
factory.createObjectLiteralExpression([
|
|
135
|
-
factory.createPropertyAssignment(factory.createIdentifier("name"), factory.createStringLiteral(astNode.name.value)),
|
|
136
|
-
factory.createPropertyAssignment(factory.createIdentifier("description"), factory.createStringLiteral(((_a = astNode.description) == null ? void 0 : _a.value) || "")),
|
|
137
|
-
factory.createPropertyAssignment(factory.createIdentifier("values"), factory.createObjectLiteralExpression((astNode.values || []).map((valueNode) => {
|
|
138
|
-
var _a2;
|
|
139
|
-
return factory.createPropertyAssignment(factory.createIdentifier(valueNode.name.value), factory.createObjectLiteralExpression([
|
|
140
|
-
factory.createPropertyAssignment(factory.createIdentifier("description"), factory.createStringLiteral(((_a2 = valueNode.description) == null ? void 0 : _a2.value) || ""))
|
|
141
|
-
]));
|
|
142
|
-
})))
|
|
143
|
-
])
|
|
144
|
-
]), factory.createTypeReferenceNode(factory.createIdentifier(SUPERMASSIVE_TYPES.ENUM_TYPE_RESOLVER), void 0));
|
|
145
|
-
}
|
|
146
|
-
function createUnionType(astNode, types) {
|
|
147
|
-
return createDeclaration(astNode.name.value, factory.createObjectLiteralExpression([
|
|
148
|
-
factory.createPropertyAssignment(factory.createIdentifier("__types"), factory.createArrayLiteralExpression(types.map((value) => factory.createStringLiteral(value)))),
|
|
149
|
-
factory.createPropertyAssignment(factory.createIdentifier("__resolveType"), factory.createIdentifier("undefined"))
|
|
150
|
-
]), factory.createTypeReferenceNode(factory.createIdentifier(SUPERMASSIVE_TYPES.UNION_TYPE_RESOLVER), void 0));
|
|
151
|
-
}
|
|
152
|
-
function createInterfaceType(astNode, implementedBy) {
|
|
153
|
-
return createDeclaration(astNode.name.value, factory.createObjectLiteralExpression([
|
|
154
|
-
factory.createPropertyAssignment(factory.createIdentifier("__implementedBy"), factory.createArrayLiteralExpression(implementedBy.map((value) => factory.createStringLiteral(value)))),
|
|
155
|
-
factory.createPropertyAssignment(factory.createIdentifier("__resolveType"), factory.createIdentifier("undefined"))
|
|
156
|
-
]), factory.createTypeReferenceNode(factory.createIdentifier(SUPERMASSIVE_TYPES.INTERFACE_TYPE_RESOLVER), void 0));
|
|
157
|
-
}
|
|
158
|
-
function createObjectType(astNode) {
|
|
159
|
-
return createDeclaration(astNode.name.value, factory.createObjectLiteralExpression(), factory.createTypeReferenceNode(factory.createIdentifier(SUPERMASSIVE_TYPES.OBJECT_TYPE_RESOLVER), void 0));
|
|
160
|
-
}
|
|
161
|
-
function createType(astNode) {
|
|
162
|
-
if (astNode.kind === Kind.LIST_TYPE) {
|
|
163
|
-
return factory.createNewExpression(factory.createIdentifier("GraphQLList"), void 0, [createType(astNode.type)]);
|
|
164
|
-
} else if (astNode.kind === Kind.NON_NULL_TYPE) {
|
|
165
|
-
return factory.createNewExpression(factory.createIdentifier("GraphQLNonNull"), void 0, [createType(astNode.type)]);
|
|
166
|
-
} else {
|
|
167
|
-
if (SPECIFIED_SCALARS[astNode.name.value]) {
|
|
168
|
-
return factory.createIdentifier(SPECIFIED_SCALARS[astNode.name.value]);
|
|
169
|
-
} else {
|
|
170
|
-
return factory.createIdentifier(astNode.name.value);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function createValue(astNode) {
|
|
175
|
-
if (astNode.kind === Kind.INT || astNode.kind === Kind.FLOAT) {
|
|
176
|
-
return factory.createNumericLiteral(astNode.value);
|
|
177
|
-
} else if (astNode.kind === Kind.BOOLEAN) {
|
|
178
|
-
return astNode.value ? factory.createTrue() : factory.createFalse();
|
|
179
|
-
} else if (astNode.kind === Kind.STRING || astNode.kind === Kind.ENUM) {
|
|
180
|
-
return factory.createStringLiteral(astNode.value);
|
|
181
|
-
} else if (astNode.kind === Kind.NULL) {
|
|
182
|
-
return factory.createNull();
|
|
183
|
-
} else if (astNode.kind === Kind.LIST) {
|
|
184
|
-
return factory.createArrayLiteralExpression(astNode.values.map((valueNode) => createValue(valueNode)));
|
|
185
|
-
} else if (astNode.kind === Kind.OBJECT) {
|
|
186
|
-
return factory.createObjectLiteralExpression(astNode.fields.map((fieldNode) => factory.createPropertyAssignment(fieldNode.name.value, createValue(fieldNode.value))));
|
|
187
|
-
} else {
|
|
188
|
-
throw new Error("Invalid value");
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
function addToSetArray(array, item) {
|
|
192
|
-
if (array.indexOf(item) === -1) {
|
|
193
|
-
array.push(item);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
export {
|
|
197
|
-
extractImplicitTypesToTypescript
|
|
198
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extractors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC"}
|
package/lib/extractors/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var extractors_exports = {};
|
|
19
|
-
__export(extractors_exports, {
|
|
20
|
-
extractImplicitTypesToTypescript: () => import_extractImplicitTypesToTypescript.extractImplicitTypesToTypescript
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(extractors_exports);
|
|
23
|
-
var import_extractImplicitTypesToTypescript = require("./extractImplicitTypesToTypescript");
|
package/lib/extractors/index.mjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import Ts from "typescript";
|
|
2
|
-
import { Project } from "@ts-morph/bootstrap";
|
|
3
|
-
export declare type TransformerFn = (program: Ts.Program) => Ts.TransformerFactory<Ts.SourceFile>;
|
|
4
|
-
export declare class Transformer {
|
|
5
|
-
private compilerOptions;
|
|
6
|
-
private filePath?;
|
|
7
|
-
private file?;
|
|
8
|
-
private mocks;
|
|
9
|
-
private sources;
|
|
10
|
-
private transformers;
|
|
11
|
-
private project?;
|
|
12
|
-
private clone;
|
|
13
|
-
addMock(moduleDescriptor: ModuleDescriptor): Transformer;
|
|
14
|
-
addSource(source: File): Transformer;
|
|
15
|
-
addTransformer(transformer: TransformerFn): Transformer;
|
|
16
|
-
addTransformers(transformers: TransformerFn[]): Transformer;
|
|
17
|
-
setCompilerOptions(options: Ts.CompilerOptions): Transformer;
|
|
18
|
-
setFile(file: File): Transformer;
|
|
19
|
-
setFilePath(filePath: string): Transformer;
|
|
20
|
-
transform(input?: string): string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @alpha
|
|
24
|
-
*/
|
|
25
|
-
export interface ModuleDescriptor {
|
|
26
|
-
name: string;
|
|
27
|
-
content: string;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @alpha
|
|
31
|
-
*/
|
|
32
|
-
export interface File {
|
|
33
|
-
path: string;
|
|
34
|
-
contents: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @alpha
|
|
38
|
-
*/
|
|
39
|
-
export interface TransformFileOptions {
|
|
40
|
-
project?: Project;
|
|
41
|
-
sources?: ReadonlyArray<File>;
|
|
42
|
-
mocks?: ReadonlyArray<ModuleDescriptor>;
|
|
43
|
-
compilerOptions?: Partial<Ts.CompilerOptions>;
|
|
44
|
-
transforms: ((program: Ts.Program) => Ts.TransformerFactory<Ts.SourceFile>)[];
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Transform a TypeScript file given a project context and transform function
|
|
48
|
-
* in a virtual filesystem
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* const file = {
|
|
53
|
-
* path: '/index.ts',
|
|
54
|
-
* contents: `
|
|
55
|
-
* import { world } from "./world";
|
|
56
|
-
* console.log("Hello,", world);
|
|
57
|
-
* `
|
|
58
|
-
* };
|
|
59
|
-
*
|
|
60
|
-
* const sources = [
|
|
61
|
-
* {
|
|
62
|
-
* path: '/world.ts',
|
|
63
|
-
* contents: `export const world = 'World'`
|
|
64
|
-
* }
|
|
65
|
-
* ];
|
|
66
|
-
*
|
|
67
|
-
* transformFile(file, {
|
|
68
|
-
* sources,
|
|
69
|
-
* transform() { ... }
|
|
70
|
-
* })
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* @alpha
|
|
74
|
-
* @param file - File to use as project root
|
|
75
|
-
* @param options - Options providing context to the transformation
|
|
76
|
-
*/
|
|
77
|
-
export declare const transformFile: (file: File, options: TransformFileOptions) => string;
|
|
78
|
-
export declare function getCompilerOptions(options?: Partial<Ts.CompilerOptions>): Ts.CompilerOptions;
|
|
79
|
-
//# sourceMappingURL=transformerTestUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformerTestUtils.d.ts","sourceRoot":"","sources":["../../src/transforms/transformerTestUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAqB,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEjE,oBAAY,aAAa,GAAG,CAC1B,OAAO,EAAE,EAAE,CAAC,OAAO,KAChB,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;AAE1C,qBAAa,WAAW;IACtB,OAAO,CAAC,eAAe,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,IAAI,CAAC,CAAO;IACpB,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,OAAO,CAAC,CAAU;IAE1B,OAAO,CAAC,KAAK;IAYN,OAAO,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,WAAW;IAMxD,SAAS,CAAC,MAAM,EAAE,IAAI,GAAG,WAAW;IAOpC,cAAc,CAAC,WAAW,EAAE,aAAa,GAAG,WAAW;IAOvD,eAAe,CAAC,YAAY,EAAE,aAAa,EAAE,GAAG,WAAW;IAO3D,kBAAkB,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,GAAG,WAAW;IAe5D,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW;IAOhC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW;IAO1C,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;CA8BzC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IAEnB,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IAEnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,OAAO,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAE9B,KAAK,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAExC,eAAe,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;IAE9C,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;CAC/E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,aAAa,SAClB,IAAI,WACD,oBAAoB,KAC5B,MAwDF,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,eAAe,CAAC,GACpC,EAAE,CAAC,eAAe,CAepB"}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __export = (target, all) => {
|
|
22
|
-
for (var name in all)
|
|
23
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
-
};
|
|
25
|
-
var __copyProps = (to, from, except, desc) => {
|
|
26
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
-
for (let key of __getOwnPropNames(from))
|
|
28
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
-
}
|
|
31
|
-
return to;
|
|
32
|
-
};
|
|
33
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
34
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
-
var transformerTestUtils_exports = {};
|
|
36
|
-
__export(transformerTestUtils_exports, {
|
|
37
|
-
Transformer: () => Transformer,
|
|
38
|
-
getCompilerOptions: () => getCompilerOptions,
|
|
39
|
-
transformFile: () => transformFile
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(transformerTestUtils_exports);
|
|
42
|
-
var import_typescript = __toESM(require("typescript"));
|
|
43
|
-
var Path = __toESM(require("path"));
|
|
44
|
-
var import_bootstrap = require("@ts-morph/bootstrap");
|
|
45
|
-
class Transformer {
|
|
46
|
-
constructor() {
|
|
47
|
-
this.compilerOptions = {};
|
|
48
|
-
this.mocks = [];
|
|
49
|
-
this.sources = [];
|
|
50
|
-
this.transformers = [];
|
|
51
|
-
}
|
|
52
|
-
clone() {
|
|
53
|
-
const target = new Transformer();
|
|
54
|
-
for (const prop in this) {
|
|
55
|
-
if (this.hasOwnProperty(prop)) {
|
|
56
|
-
target[prop] = this[prop];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return target;
|
|
60
|
-
}
|
|
61
|
-
addMock(moduleDescriptor) {
|
|
62
|
-
const clone = this.clone();
|
|
63
|
-
clone.mocks.push(moduleDescriptor);
|
|
64
|
-
return clone;
|
|
65
|
-
}
|
|
66
|
-
addSource(source) {
|
|
67
|
-
const clone = this.clone();
|
|
68
|
-
clone.sources.push(source);
|
|
69
|
-
return clone;
|
|
70
|
-
}
|
|
71
|
-
addTransformer(transformer) {
|
|
72
|
-
const clone = this.clone();
|
|
73
|
-
clone.transformers.push(transformer);
|
|
74
|
-
return clone;
|
|
75
|
-
}
|
|
76
|
-
addTransformers(transformers) {
|
|
77
|
-
const clone = this.clone();
|
|
78
|
-
clone.transformers.push(...transformers);
|
|
79
|
-
return clone;
|
|
80
|
-
}
|
|
81
|
-
setCompilerOptions(options) {
|
|
82
|
-
const clone = this.clone();
|
|
83
|
-
clone.compilerOptions = options;
|
|
84
|
-
if (clone.project) {
|
|
85
|
-
clone.project = (0, import_bootstrap.createProjectSync)({
|
|
86
|
-
useInMemoryFileSystem: true,
|
|
87
|
-
compilerOptions: getCompilerOptions(clone.compilerOptions)
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return clone;
|
|
91
|
-
}
|
|
92
|
-
setFile(file) {
|
|
93
|
-
const clone = this.clone();
|
|
94
|
-
clone.file = file;
|
|
95
|
-
return clone;
|
|
96
|
-
}
|
|
97
|
-
setFilePath(filePath) {
|
|
98
|
-
const clone = this.clone();
|
|
99
|
-
clone.filePath = filePath;
|
|
100
|
-
return clone;
|
|
101
|
-
}
|
|
102
|
-
transform(input) {
|
|
103
|
-
this.project = this.project || (0, import_bootstrap.createProjectSync)({
|
|
104
|
-
useInMemoryFileSystem: true,
|
|
105
|
-
compilerOptions: getCompilerOptions(this.compilerOptions)
|
|
106
|
-
});
|
|
107
|
-
const filePath = typeof this.filePath === "string" ? this.filePath : "/index.ts";
|
|
108
|
-
const file = typeof input === "string" ? { path: filePath, contents: input } : this.file;
|
|
109
|
-
if (!file) {
|
|
110
|
-
throw new Error(`transform must be called on Transformer with file or with string input`);
|
|
111
|
-
}
|
|
112
|
-
return transformFile(file, {
|
|
113
|
-
project: this.project,
|
|
114
|
-
compilerOptions: this.compilerOptions,
|
|
115
|
-
mocks: this.mocks,
|
|
116
|
-
sources: this.sources,
|
|
117
|
-
transforms: this.transformers
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const transformFile = (file, options) => {
|
|
122
|
-
const project = options.project || (0, import_bootstrap.createProjectSync)({
|
|
123
|
-
useInMemoryFileSystem: true,
|
|
124
|
-
compilerOptions: getCompilerOptions(options.compilerOptions)
|
|
125
|
-
});
|
|
126
|
-
project.createSourceFile(file.path, file.contents);
|
|
127
|
-
(options.sources || []).forEach((source) => project.createSourceFile(source.path, source.contents));
|
|
128
|
-
(options.mocks || []).forEach((mock) => {
|
|
129
|
-
const base = `/node_modules/${mock.name}`;
|
|
130
|
-
project.createSourceFile(`${base}/index.ts`, mock.content);
|
|
131
|
-
project.fileSystem.writeFileSync(`${base}/package.json`, JSON.stringify({ name: mock.name, main: "./src/index.ts" }));
|
|
132
|
-
});
|
|
133
|
-
const program = project.createProgram();
|
|
134
|
-
const { emitSkipped, diagnostics } = program.emit(program.getSourceFile(file.path), void 0, void 0, false, {
|
|
135
|
-
before: options.transforms.map((t) => t(program))
|
|
136
|
-
});
|
|
137
|
-
if (emitSkipped) {
|
|
138
|
-
throw new Error(project.formatDiagnosticsWithColorAndContext(diagnostics));
|
|
139
|
-
}
|
|
140
|
-
const inFile = program.getSourceFile(file.path);
|
|
141
|
-
if (!inFile) {
|
|
142
|
-
throw new Error(`Could not get SourceFile for ${file.path}`);
|
|
143
|
-
}
|
|
144
|
-
if (!inFile) {
|
|
145
|
-
throw new Error(`Could not determine ArtifactFile for ${file.path}`);
|
|
146
|
-
}
|
|
147
|
-
const fileArtifactPath = getFileArtifactPath(inFile, program);
|
|
148
|
-
if (!fileArtifactPath) {
|
|
149
|
-
throw new Error(`Could not determine fileArtifactPath for ${file.path}`);
|
|
150
|
-
}
|
|
151
|
-
return String(project.fileSystem.readFileSync(fileArtifactPath));
|
|
152
|
-
};
|
|
153
|
-
function getCompilerOptions(options) {
|
|
154
|
-
return __spreadValues({
|
|
155
|
-
outDir: "/dist",
|
|
156
|
-
lib: ["/node_modules/typescript/lib/lib.esnext.full.d.ts"],
|
|
157
|
-
module: import_typescript.default.ModuleKind.ESNext,
|
|
158
|
-
moduleResolution: import_typescript.default.ModuleResolutionKind.NodeJs,
|
|
159
|
-
suppressImplicitAnyIndexErrors: true,
|
|
160
|
-
resolveJsonModule: true,
|
|
161
|
-
skipLibCheck: true,
|
|
162
|
-
target: import_typescript.default.ScriptTarget.ESNext,
|
|
163
|
-
types: [],
|
|
164
|
-
noEmitOnError: true,
|
|
165
|
-
jsx: import_typescript.default.JsxEmit.Preserve
|
|
166
|
-
}, options || {});
|
|
167
|
-
}
|
|
168
|
-
function getFileArtifactPath(file, program) {
|
|
169
|
-
const options = program.getCompilerOptions();
|
|
170
|
-
const extname = Path.extname(file.fileName);
|
|
171
|
-
const basename = Path.basename(file.fileName, extname);
|
|
172
|
-
const artifactExtname = extname === ".tsx" && options.jsx === import_typescript.default.JsxEmit.Preserve ? ".jsx" : ".js";
|
|
173
|
-
return Path.join(options.outDir || ".", `${basename}${artifactExtname}`);
|
|
174
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// src/transforms/transformerTestUtils.ts
|
|
19
|
-
import Ts from "typescript";
|
|
20
|
-
import * as Path from "path";
|
|
21
|
-
import { createProjectSync } from "@ts-morph/bootstrap";
|
|
22
|
-
var Transformer = class {
|
|
23
|
-
constructor() {
|
|
24
|
-
this.compilerOptions = {};
|
|
25
|
-
this.mocks = [];
|
|
26
|
-
this.sources = [];
|
|
27
|
-
this.transformers = [];
|
|
28
|
-
}
|
|
29
|
-
clone() {
|
|
30
|
-
const target = new Transformer();
|
|
31
|
-
for (const prop in this) {
|
|
32
|
-
if (this.hasOwnProperty(prop)) {
|
|
33
|
-
target[prop] = this[prop];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return target;
|
|
37
|
-
}
|
|
38
|
-
addMock(moduleDescriptor) {
|
|
39
|
-
const clone = this.clone();
|
|
40
|
-
clone.mocks.push(moduleDescriptor);
|
|
41
|
-
return clone;
|
|
42
|
-
}
|
|
43
|
-
addSource(source) {
|
|
44
|
-
const clone = this.clone();
|
|
45
|
-
clone.sources.push(source);
|
|
46
|
-
return clone;
|
|
47
|
-
}
|
|
48
|
-
addTransformer(transformer) {
|
|
49
|
-
const clone = this.clone();
|
|
50
|
-
clone.transformers.push(transformer);
|
|
51
|
-
return clone;
|
|
52
|
-
}
|
|
53
|
-
addTransformers(transformers) {
|
|
54
|
-
const clone = this.clone();
|
|
55
|
-
clone.transformers.push(...transformers);
|
|
56
|
-
return clone;
|
|
57
|
-
}
|
|
58
|
-
setCompilerOptions(options) {
|
|
59
|
-
const clone = this.clone();
|
|
60
|
-
clone.compilerOptions = options;
|
|
61
|
-
if (clone.project) {
|
|
62
|
-
clone.project = createProjectSync({
|
|
63
|
-
useInMemoryFileSystem: true,
|
|
64
|
-
compilerOptions: getCompilerOptions(clone.compilerOptions)
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return clone;
|
|
68
|
-
}
|
|
69
|
-
setFile(file) {
|
|
70
|
-
const clone = this.clone();
|
|
71
|
-
clone.file = file;
|
|
72
|
-
return clone;
|
|
73
|
-
}
|
|
74
|
-
setFilePath(filePath) {
|
|
75
|
-
const clone = this.clone();
|
|
76
|
-
clone.filePath = filePath;
|
|
77
|
-
return clone;
|
|
78
|
-
}
|
|
79
|
-
transform(input) {
|
|
80
|
-
this.project = this.project || createProjectSync({
|
|
81
|
-
useInMemoryFileSystem: true,
|
|
82
|
-
compilerOptions: getCompilerOptions(this.compilerOptions)
|
|
83
|
-
});
|
|
84
|
-
const filePath = typeof this.filePath === "string" ? this.filePath : "/index.ts";
|
|
85
|
-
const file = typeof input === "string" ? { path: filePath, contents: input } : this.file;
|
|
86
|
-
if (!file) {
|
|
87
|
-
throw new Error(`transform must be called on Transformer with file or with string input`);
|
|
88
|
-
}
|
|
89
|
-
return transformFile(file, {
|
|
90
|
-
project: this.project,
|
|
91
|
-
compilerOptions: this.compilerOptions,
|
|
92
|
-
mocks: this.mocks,
|
|
93
|
-
sources: this.sources,
|
|
94
|
-
transforms: this.transformers
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var transformFile = (file, options) => {
|
|
99
|
-
const project = options.project || createProjectSync({
|
|
100
|
-
useInMemoryFileSystem: true,
|
|
101
|
-
compilerOptions: getCompilerOptions(options.compilerOptions)
|
|
102
|
-
});
|
|
103
|
-
project.createSourceFile(file.path, file.contents);
|
|
104
|
-
(options.sources || []).forEach((source) => project.createSourceFile(source.path, source.contents));
|
|
105
|
-
(options.mocks || []).forEach((mock) => {
|
|
106
|
-
const base = `/node_modules/${mock.name}`;
|
|
107
|
-
project.createSourceFile(`${base}/index.ts`, mock.content);
|
|
108
|
-
project.fileSystem.writeFileSync(`${base}/package.json`, JSON.stringify({ name: mock.name, main: "./src/index.ts" }));
|
|
109
|
-
});
|
|
110
|
-
const program = project.createProgram();
|
|
111
|
-
const { emitSkipped, diagnostics } = program.emit(program.getSourceFile(file.path), void 0, void 0, false, {
|
|
112
|
-
before: options.transforms.map((t) => t(program))
|
|
113
|
-
});
|
|
114
|
-
if (emitSkipped) {
|
|
115
|
-
throw new Error(project.formatDiagnosticsWithColorAndContext(diagnostics));
|
|
116
|
-
}
|
|
117
|
-
const inFile = program.getSourceFile(file.path);
|
|
118
|
-
if (!inFile) {
|
|
119
|
-
throw new Error(`Could not get SourceFile for ${file.path}`);
|
|
120
|
-
}
|
|
121
|
-
if (!inFile) {
|
|
122
|
-
throw new Error(`Could not determine ArtifactFile for ${file.path}`);
|
|
123
|
-
}
|
|
124
|
-
const fileArtifactPath = getFileArtifactPath(inFile, program);
|
|
125
|
-
if (!fileArtifactPath) {
|
|
126
|
-
throw new Error(`Could not determine fileArtifactPath for ${file.path}`);
|
|
127
|
-
}
|
|
128
|
-
return String(project.fileSystem.readFileSync(fileArtifactPath));
|
|
129
|
-
};
|
|
130
|
-
function getCompilerOptions(options) {
|
|
131
|
-
return __spreadValues({
|
|
132
|
-
outDir: "/dist",
|
|
133
|
-
lib: ["/node_modules/typescript/lib/lib.esnext.full.d.ts"],
|
|
134
|
-
module: Ts.ModuleKind.ESNext,
|
|
135
|
-
moduleResolution: Ts.ModuleResolutionKind.NodeJs,
|
|
136
|
-
suppressImplicitAnyIndexErrors: true,
|
|
137
|
-
resolveJsonModule: true,
|
|
138
|
-
skipLibCheck: true,
|
|
139
|
-
target: Ts.ScriptTarget.ESNext,
|
|
140
|
-
types: [],
|
|
141
|
-
noEmitOnError: true,
|
|
142
|
-
jsx: Ts.JsxEmit.Preserve
|
|
143
|
-
}, options || {});
|
|
144
|
-
}
|
|
145
|
-
function getFileArtifactPath(file, program) {
|
|
146
|
-
const options = program.getCompilerOptions();
|
|
147
|
-
const extname2 = Path.extname(file.fileName);
|
|
148
|
-
const basename2 = Path.basename(file.fileName, extname2);
|
|
149
|
-
const artifactExtname = extname2 === ".tsx" && options.jsx === Ts.JsxEmit.Preserve ? ".jsx" : ".js";
|
|
150
|
-
return Path.join(options.outDir || ".", `${basename2}${artifactExtname}`);
|
|
151
|
-
}
|
|
152
|
-
export {
|
|
153
|
-
Transformer,
|
|
154
|
-
getCompilerOptions,
|
|
155
|
-
transformFile
|
|
156
|
-
};
|