typeorm 0.2.42-dev.90a8deb → 0.2.42-dev.92c3e79
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 +38 -0
- package/browser/common/RelationType.d.ts +14 -0
- package/browser/common/RelationType.js +3 -0
- package/browser/common/RelationType.js.map +1 -0
- package/browser/connection/BaseConnectionOptions.d.ts +5 -0
- package/browser/connection/BaseConnectionOptions.js.map +1 -1
- package/browser/connection/Connection.d.ts +5 -1
- package/browser/connection/Connection.js +46 -30
- package/browser/connection/Connection.js.map +1 -1
- package/browser/connection/ConnectionMetadataBuilder.d.ts +3 -3
- package/browser/connection/ConnectionMetadataBuilder.js +54 -22
- package/browser/connection/ConnectionMetadataBuilder.js.map +1 -1
- package/browser/connection/ConnectionOptionsReader.js +33 -28
- package/browser/connection/ConnectionOptionsReader.js.map +1 -1
- package/browser/connection/options-reader/ConnectionOptionsEnvReader.js +1 -0
- package/browser/connection/options-reader/ConnectionOptionsEnvReader.js.map +1 -1
- package/browser/decorator/Unique.d.ts +5 -4
- package/browser/decorator/Unique.js +7 -3
- package/browser/decorator/Unique.js.map +1 -1
- package/browser/decorator/options/RelationOptions.d.ts +1 -1
- package/browser/decorator/options/RelationOptions.js.map +1 -1
- package/browser/decorator/options/UniqueOptions.d.ts +10 -0
- package/browser/decorator/options/UniqueOptions.js +3 -0
- package/browser/decorator/options/UniqueOptions.js.map +1 -0
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/browser/driver/better-sqlite3/BetterSqlite3Driver.js +7 -5
- package/browser/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/driver/oracle/OracleQueryRunner.js +1 -1
- package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +12 -5
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.js +1 -1
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/driver/sqlite/SqliteDriver.js +11 -10
- package/browser/driver/sqlite/SqliteDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/browser/entity-manager/MongoEntityManager.js +2 -1
- package/browser/entity-manager/MongoEntityManager.js.map +1 -1
- package/browser/entity-schema/EntitySchemaRelationOptions.d.ts +1 -1
- package/browser/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
- package/browser/entity-schema/EntitySchemaTransformer.js +2 -1
- package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/browser/entity-schema/EntitySchemaUniqueOptions.d.ts +5 -0
- package/browser/entity-schema/EntitySchemaUniqueOptions.js.map +1 -1
- package/browser/find-options/FindOneOptions.d.ts +6 -0
- package/browser/find-options/FindOneOptions.js.map +1 -1
- package/browser/find-options/FindOptionsUtils.js +4 -0
- package/browser/find-options/FindOptionsUtils.js.map +1 -1
- package/browser/find-options/operator/Like.d.ts +1 -1
- package/browser/find-options/operator/Like.js +1 -1
- package/browser/find-options/operator/Like.js.map +1 -1
- package/browser/globals.js +34 -7
- package/browser/globals.js.map +1 -1
- package/browser/index.d.ts +2 -0
- package/browser/index.js +2 -0
- package/browser/index.js.map +1 -1
- package/browser/metadata/RelationMetadata.d.ts +1 -1
- package/browser/metadata/RelationMetadata.js.map +1 -1
- package/browser/metadata/UniqueMetadata.d.ts +5 -0
- package/browser/metadata/UniqueMetadata.js +1 -0
- package/browser/metadata/UniqueMetadata.js.map +1 -1
- package/browser/metadata-args/UniqueMetadataArgs.d.ts +5 -0
- package/browser/metadata-args/UniqueMetadataArgs.js.map +1 -1
- package/browser/metadata-builder/EntityMetadataValidator.js +1 -0
- package/browser/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +1 -1
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/persistence/subject-builder/OneToManySubjectBuilder.js +3 -0
- package/browser/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/browser/query-builder/DeleteQueryBuilder.d.ts +3 -1
- package/browser/query-builder/DeleteQueryBuilder.js +3 -1
- package/browser/query-builder/DeleteQueryBuilder.js.map +1 -1
- package/browser/query-builder/NotBrackets.d.ts +7 -0
- package/browser/query-builder/NotBrackets.js +16 -0
- package/browser/query-builder/NotBrackets.js.map +1 -0
- package/browser/query-builder/QueryBuilder.d.ts +2 -1
- package/browser/query-builder/QueryBuilder.js +2 -1
- package/browser/query-builder/QueryBuilder.js.map +1 -1
- package/browser/query-builder/RelationLoader.js +11 -6
- package/browser/query-builder/RelationLoader.js.map +1 -1
- package/browser/query-builder/UpdateQueryBuilder.d.ts +3 -1
- package/browser/query-builder/UpdateQueryBuilder.js +10 -5
- package/browser/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/browser/query-builder/WhereExpressionBuilder.d.ts +3 -1
- package/browser/query-builder/WhereExpressionBuilder.js.map +1 -1
- package/browser/query-runner/BaseQueryRunner.d.ts +2 -2
- package/browser/query-runner/BaseQueryRunner.js +3 -3
- package/browser/query-runner/BaseQueryRunner.js.map +1 -1
- package/browser/repository/TreeRepository.js +1 -1
- package/browser/repository/TreeRepository.js.map +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/browser/schema-builder/options/TableUniqueOptions.d.ts +5 -0
- package/browser/schema-builder/options/TableUniqueOptions.js.map +1 -1
- package/browser/schema-builder/table/TableUnique.d.ts +5 -0
- package/browser/schema-builder/table/TableUnique.js +5 -2
- package/browser/schema-builder/table/TableUnique.js.map +1 -1
- package/browser/util/DirectoryExportedClassesLoader.d.ts +1 -1
- package/browser/util/DirectoryExportedClassesLoader.js +55 -31
- package/browser/util/DirectoryExportedClassesLoader.js.map +1 -1
- package/browser/util/ImportUtils.d.ts +1 -0
- package/browser/util/ImportUtils.js +90 -0
- package/browser/util/ImportUtils.js.map +1 -0
- package/commands/CommandUtils.d.ts +4 -0
- package/commands/CommandUtils.js +10 -0
- package/commands/CommandUtils.js.map +1 -1
- package/commands/InitCommand.d.ts +9 -7
- package/commands/InitCommand.js +72 -43
- package/commands/InitCommand.js.map +1 -1
- package/commands/MigrationCreateCommand.d.ts +2 -0
- package/commands/MigrationCreateCommand.js +7 -1
- package/commands/MigrationCreateCommand.js.map +1 -1
- package/commands/MigrationGenerateCommand.d.ts +2 -0
- package/commands/MigrationGenerateCommand.js +7 -1
- package/commands/MigrationGenerateCommand.js.map +1 -1
- package/common/RelationType.d.ts +14 -0
- package/common/RelationType.js +4 -0
- package/common/RelationType.js.map +1 -0
- package/connection/BaseConnectionOptions.d.ts +5 -0
- package/connection/BaseConnectionOptions.js.map +1 -1
- package/connection/Connection.d.ts +5 -1
- package/connection/Connection.js +46 -30
- package/connection/Connection.js.map +1 -1
- package/connection/ConnectionMetadataBuilder.d.ts +3 -3
- package/connection/ConnectionMetadataBuilder.js +53 -21
- package/connection/ConnectionMetadataBuilder.js.map +1 -1
- package/connection/ConnectionOptionsReader.js +32 -27
- package/connection/ConnectionOptionsReader.js.map +1 -1
- package/connection/options-reader/ConnectionOptionsEnvReader.js +1 -0
- package/connection/options-reader/ConnectionOptionsEnvReader.js.map +1 -1
- package/decorator/Unique.d.ts +5 -4
- package/decorator/Unique.js +7 -3
- package/decorator/Unique.js.map +1 -1
- package/decorator/options/RelationOptions.d.ts +1 -1
- package/decorator/options/RelationOptions.js.map +1 -1
- package/decorator/options/UniqueOptions.d.ts +10 -0
- package/decorator/options/UniqueOptions.js +4 -0
- package/decorator/options/UniqueOptions.js.map +1 -0
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/driver/better-sqlite3/BetterSqlite3Driver.js +7 -5
- package/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.js +1 -1
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/driver/oracle/OracleQueryRunner.js +1 -1
- package/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +12 -5
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sap/SapQueryRunner.js +1 -1
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/sqlite/SqliteDriver.js +11 -10
- package/driver/sqlite/SqliteDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/entity-manager/MongoEntityManager.js +2 -1
- package/entity-manager/MongoEntityManager.js.map +1 -1
- package/entity-schema/EntitySchemaRelationOptions.d.ts +1 -1
- package/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
- package/entity-schema/EntitySchemaTransformer.js +2 -1
- package/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/entity-schema/EntitySchemaUniqueOptions.d.ts +5 -0
- package/entity-schema/EntitySchemaUniqueOptions.js.map +1 -1
- package/find-options/FindOneOptions.d.ts +6 -0
- package/find-options/FindOneOptions.js.map +1 -1
- package/find-options/FindOptionsUtils.js +4 -0
- package/find-options/FindOptionsUtils.js.map +1 -1
- package/find-options/operator/Like.d.ts +1 -1
- package/find-options/operator/Like.js +1 -1
- package/find-options/operator/Like.js.map +1 -1
- package/globals.js +33 -6
- package/globals.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +4 -1
- package/index.js.map +1 -1
- package/index.mjs +352 -0
- package/metadata/RelationMetadata.d.ts +1 -1
- package/metadata/RelationMetadata.js.map +1 -1
- package/metadata/UniqueMetadata.d.ts +5 -0
- package/metadata/UniqueMetadata.js +1 -0
- package/metadata/UniqueMetadata.js.map +1 -1
- package/metadata-args/UniqueMetadataArgs.d.ts +5 -0
- package/metadata-args/UniqueMetadataArgs.js.map +1 -1
- package/metadata-builder/EntityMetadataValidator.js +1 -0
- package/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/migration/MigrationExecutor.js +1 -1
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/persistence/subject-builder/OneToManySubjectBuilder.js +3 -0
- package/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/query-builder/DeleteQueryBuilder.d.ts +3 -1
- package/query-builder/DeleteQueryBuilder.js +3 -1
- package/query-builder/DeleteQueryBuilder.js.map +1 -1
- package/query-builder/NotBrackets.d.ts +7 -0
- package/query-builder/NotBrackets.js +19 -0
- package/query-builder/NotBrackets.js.map +1 -0
- package/query-builder/QueryBuilder.d.ts +2 -1
- package/query-builder/QueryBuilder.js +2 -1
- package/query-builder/QueryBuilder.js.map +1 -1
- package/query-builder/RelationLoader.js +11 -6
- package/query-builder/RelationLoader.js.map +1 -1
- package/query-builder/UpdateQueryBuilder.d.ts +3 -1
- package/query-builder/UpdateQueryBuilder.js +10 -5
- package/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/query-builder/WhereExpressionBuilder.d.ts +3 -1
- package/query-builder/WhereExpressionBuilder.js.map +1 -1
- package/query-runner/BaseQueryRunner.d.ts +2 -2
- package/query-runner/BaseQueryRunner.js +3 -3
- package/query-runner/BaseQueryRunner.js.map +1 -1
- package/repository/TreeRepository.js +1 -1
- package/repository/TreeRepository.js.map +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/schema-builder/options/TableUniqueOptions.d.ts +5 -0
- package/schema-builder/options/TableUniqueOptions.js.map +1 -1
- package/schema-builder/table/TableUnique.d.ts +5 -0
- package/schema-builder/table/TableUnique.js +5 -2
- package/schema-builder/table/TableUnique.js.map +1 -1
- package/util/DirectoryExportedClassesLoader.d.ts +1 -1
- package/util/DirectoryExportedClassesLoader.js +54 -31
- package/util/DirectoryExportedClassesLoader.js.map +1 -1
- package/util/ImportUtils.d.ts +1 -0
- package/util/ImportUtils.js +94 -0
- package/util/ImportUtils.js.map +1 -0
|
@@ -1,42 +1,66 @@
|
|
|
1
|
+
import { __awaiter, __generator, __read } from "tslib";
|
|
1
2
|
import glob from "glob";
|
|
2
3
|
import { PlatformTools } from "../platform/PlatformTools";
|
|
3
4
|
import { EntitySchema } from "../entity-schema/EntitySchema";
|
|
5
|
+
import { importOrRequireFile } from "./ImportUtils";
|
|
4
6
|
/**
|
|
5
7
|
* Loads all exported classes from the given directory.
|
|
6
8
|
*/
|
|
7
9
|
export function importClassesFromDirectories(logger, directories, formats) {
|
|
8
|
-
if (formats === void 0) { formats = [".js", ".cjs", ".ts"]; }
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
if (formats === void 0) { formats = [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]; }
|
|
11
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12
|
+
function loadFileClasses(exported, allLoaded) {
|
|
13
|
+
if (typeof exported === "function" || exported instanceof EntitySchema) {
|
|
14
|
+
allLoaded.push(exported);
|
|
15
|
+
}
|
|
16
|
+
else if (Array.isArray(exported)) {
|
|
17
|
+
exported.forEach(function (i) { return loadFileClasses(i, allLoaded); });
|
|
18
|
+
}
|
|
19
|
+
else if (typeof exported === "object" && exported !== null) {
|
|
20
|
+
Object.keys(exported).forEach(function (key) { return loadFileClasses(exported[key], allLoaded); });
|
|
21
|
+
}
|
|
22
|
+
return allLoaded;
|
|
15
23
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
var logLevel, classesNotFoundMessage, classesFoundMessage, allFiles, dirPromises, dirs;
|
|
25
|
+
var _this = this;
|
|
26
|
+
return __generator(this, function (_a) {
|
|
27
|
+
switch (_a.label) {
|
|
28
|
+
case 0:
|
|
29
|
+
logLevel = "info";
|
|
30
|
+
classesNotFoundMessage = "No classes were found using the provided glob pattern: ";
|
|
31
|
+
classesFoundMessage = "All classes found using provided glob pattern";
|
|
32
|
+
allFiles = directories.reduce(function (allDirs, dir) {
|
|
33
|
+
return allDirs.concat(glob.sync(PlatformTools.pathNormalize(dir)));
|
|
34
|
+
}, []);
|
|
35
|
+
if (directories.length > 0 && allFiles.length === 0) {
|
|
36
|
+
logger.log(logLevel, classesNotFoundMessage + " \"" + directories + "\"");
|
|
37
|
+
}
|
|
38
|
+
else if (allFiles.length > 0) {
|
|
39
|
+
logger.log(logLevel, classesFoundMessage + " \"" + directories + "\" : \"" + allFiles + "\"");
|
|
40
|
+
}
|
|
41
|
+
dirPromises = allFiles
|
|
42
|
+
.filter(function (file) {
|
|
43
|
+
var dtsExtension = file.substring(file.length - 5, file.length);
|
|
44
|
+
return formats.indexOf(PlatformTools.pathExtname(file)) !== -1 && dtsExtension !== ".d.ts";
|
|
45
|
+
})
|
|
46
|
+
.map(function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
47
|
+
var _a, importOrRequireResult;
|
|
48
|
+
return __generator(this, function (_b) {
|
|
49
|
+
switch (_b.label) {
|
|
50
|
+
case 0: return [4 /*yield*/, importOrRequireFile(PlatformTools.pathResolve(file))];
|
|
51
|
+
case 1:
|
|
52
|
+
_a = __read.apply(void 0, [_b.sent(), 1]), importOrRequireResult = _a[0];
|
|
53
|
+
return [2 /*return*/, importOrRequireResult];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}); });
|
|
57
|
+
return [4 /*yield*/, Promise.all(dirPromises)];
|
|
58
|
+
case 1:
|
|
59
|
+
dirs = _a.sent();
|
|
60
|
+
return [2 /*return*/, loadFileClasses(dirs, [])];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
40
64
|
}
|
|
41
65
|
/**
|
|
42
66
|
* Loads all json files from the given directory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/util/DirectoryExportedClassesLoader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAE3D;;GAEG;AACH,MAAM,
|
|
1
|
+
{"version":3,"sources":["../browser/src/util/DirectoryExportedClassesLoader.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD;;GAEG;AACH,MAAM,UAAgB,4BAA4B,CAAC,MAAc,EAAE,WAAqB,EAAE,OAAwD;IAAxD,wBAAA,EAAA,WAAW,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;;QAK9I,SAAS,eAAe,CAAC,QAAa,EAAE,SAAqB;YACzD,IAAI,OAAO,QAAQ,KAAK,UAAU,IAAI,QAAQ,YAAY,YAAY,E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D,CAAC","file":"DirectoryExportedClassesLoader.js","sourcesContent":["import glob from \"glob\";\nimport {PlatformTools} from \"../platform/PlatformTools\";\nimport {EntitySchema} from \"../entity-schema/EntitySchema\";\nimport {Logger} from \"../logger/Logger\";\nimport {importOrRequireFile} from \"./ImportUtils\";\n/**\n * Loads all exported classes from the given directory.\n */\nexport async function importClassesFromDirectories(logger: Logger, directories: string[], formats = [\".js\", \".mjs\", \".cjs\", \".ts\", \".mts\", \".cts\"]): Promise<Function[]> {\n\n const logLevel = \"info\";\n const classesNotFoundMessage = \"No classes were found using the provided glob pattern: \";\n const classesFoundMessage = \"All classes found using provided glob pattern\";\n function loadFileClasses(exported: any, allLoaded: Function[]) {\n if (typeof exported === \"function\" || exported instanceof EntitySchema) {\n allLoaded.push(exported);\n\n } else if (Array.isArray(exported)) {\n exported.forEach((i: any) => loadFileClasses(i, allLoaded));\n\n } else if (typeof exported === \"object\" && exported !== null) {\n Object.keys(exported).forEach(key => loadFileClasses(exported[key], allLoaded));\n\n }\n return allLoaded;\n }\n\n const allFiles = directories.reduce((allDirs, dir) => {\n return allDirs.concat(glob.sync(PlatformTools.pathNormalize(dir)));\n }, [] as string[]);\n\n if (directories.length > 0 && allFiles.length === 0) {\n logger.log(logLevel, `${classesNotFoundMessage} \"${directories}\"`);\n } else if (allFiles.length > 0) {\n logger.log(logLevel, `${classesFoundMessage} \"${directories}\" : \"${allFiles}\"`);\n }\n const dirPromises = allFiles\n .filter(file => {\n const dtsExtension = file.substring(file.length - 5, file.length);\n return formats.indexOf(PlatformTools.pathExtname(file)) !== -1 && dtsExtension !== \".d.ts\";\n })\n .map(async file => {\n const [importOrRequireResult] = await importOrRequireFile(PlatformTools.pathResolve(file));\n return importOrRequireResult;\n });\n\n const dirs = await Promise.all(dirPromises);\n\n return loadFileClasses(dirs, []);\n}\n\n/**\n * Loads all json files from the given directory.\n */\nexport function importJsonsFromDirectories(directories: string[], format = \".json\"): any[] {\n\n const allFiles = directories.reduce((allDirs, dir) => {\n return allDirs.concat(glob.sync(PlatformTools.pathNormalize(dir)));\n }, [] as string[]);\n\n return allFiles\n .filter(file => PlatformTools.pathExtname(file) === format)\n .map(file => require(PlatformTools.pathResolve(file)));\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function importOrRequireFile(filePath: string): Promise<[result: any, moduleType: "esm" | "commonjs"]>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
export function importOrRequireFile(filePath) {
|
|
5
|
+
var _a;
|
|
6
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7
|
+
var tryToImport, tryToRequire, extension, packageJson, isModule;
|
|
8
|
+
var _this = this;
|
|
9
|
+
return __generator(this, function (_b) {
|
|
10
|
+
switch (_b.label) {
|
|
11
|
+
case 0:
|
|
12
|
+
tryToImport = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
13
|
+
return __generator(this, function (_a) {
|
|
14
|
+
switch (_a.label) {
|
|
15
|
+
case 0: return [4 /*yield*/, Function("return filePath => import(filePath)")()(filePath)];
|
|
16
|
+
case 1:
|
|
17
|
+
// `Function` is required to make sure the `import` statement wil stay `import` after
|
|
18
|
+
// transpilation and won't be converted to `require`
|
|
19
|
+
return [2 /*return*/, [_a.sent(), "esm"]];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}); };
|
|
23
|
+
tryToRequire = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
24
|
+
return __generator(this, function (_a) {
|
|
25
|
+
return [2 /*return*/, [require(filePath), "commonjs"]];
|
|
26
|
+
});
|
|
27
|
+
}); };
|
|
28
|
+
extension = filePath.substring(filePath.lastIndexOf(".") + ".".length);
|
|
29
|
+
if (!(extension === "mjs" || extension === "mts")) return [3 /*break*/, 1];
|
|
30
|
+
return [2 /*return*/, tryToImport()];
|
|
31
|
+
case 1:
|
|
32
|
+
if (!(extension === "cjs" || extension === "cts")) return [3 /*break*/, 2];
|
|
33
|
+
return [2 /*return*/, tryToRequire()];
|
|
34
|
+
case 2:
|
|
35
|
+
if (!(extension === "js" || extension === "ts")) return [3 /*break*/, 4];
|
|
36
|
+
return [4 /*yield*/, getNearestPackageJson(filePath)];
|
|
37
|
+
case 3:
|
|
38
|
+
packageJson = _b.sent();
|
|
39
|
+
if (packageJson != null) {
|
|
40
|
+
isModule = ((_a = packageJson) === null || _a === void 0 ? void 0 : _a.type) === "module";
|
|
41
|
+
if (isModule)
|
|
42
|
+
return [2 /*return*/, tryToImport()];
|
|
43
|
+
else
|
|
44
|
+
return [2 /*return*/, tryToRequire()];
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
return [2 /*return*/, tryToRequire()];
|
|
48
|
+
_b.label = 4;
|
|
49
|
+
case 4: return [2 /*return*/, tryToRequire()];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function getNearestPackageJson(filePath) {
|
|
55
|
+
return new Promise(function (accept) {
|
|
56
|
+
var currentPath = filePath;
|
|
57
|
+
function searchPackageJson() {
|
|
58
|
+
var nextPath = path.dirname(currentPath);
|
|
59
|
+
if (currentPath === nextPath) // the top of the file tree is reached
|
|
60
|
+
accept(null);
|
|
61
|
+
else {
|
|
62
|
+
currentPath = nextPath;
|
|
63
|
+
var potentialPackageJson_1 = path.join(currentPath, "package.json");
|
|
64
|
+
fs.stat(potentialPackageJson_1, function (err, stats) {
|
|
65
|
+
if (err != null)
|
|
66
|
+
searchPackageJson();
|
|
67
|
+
else if (stats.isFile()) {
|
|
68
|
+
fs.readFile(potentialPackageJson_1, "utf8", function (err, data) {
|
|
69
|
+
if (err != null)
|
|
70
|
+
accept(null);
|
|
71
|
+
else {
|
|
72
|
+
try {
|
|
73
|
+
accept(JSON.parse(data));
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
accept(null);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else
|
|
82
|
+
searchPackageJson();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
searchPackageJson();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=ImportUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../browser/src/util/ImportUtils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAgB,mBAAmB,CAAC,QAAgB;;;;;;;;oBAChD,WAAW,GAAG;;;wCAGR,qBAAM,QAAQ,CAAC,qCAAqC,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAA;;gCAFzE,qFAAqF;gCACrF,oDAAoD;gCACpD,uBAAQ,SAAiE,EAAE,KAAK,GAAE;;;yBACrF,CAAC;oBACI,YAAY,GAAG;;4BACjB,sBAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,EAAC;;yBAC1C,CAAC;oBAEI,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;yBAEzE,CAAA,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,KAAK,CAAA,EAA1C,wBAA0C;oBAC1C,sBAAO,WAAW,EAAE,EAAC;;yBAChB,CAAA,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,KAAK,CAAA,EAA1C,wBAA0C;oBAC/C,sBAAO,YAAY,EAAE,EAAC;;yBACjB,CAAA,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,IAAI,CAAA,EAAxC,wBAAwC;oBACzB,qBAAM,qBAAqB,CAAC,QAAQ,CAAC,EAAA;;oBAAnD,WAAW,GAAG,SAAqC;oBAEzD,I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C5B,CAAC,CAAC,CAAC;aACN;QACL,CAAC;QAED,iBAAiB,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACP,CAAC","file":"ImportUtils.js","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nexport async function importOrRequireFile(filePath: string): Promise<[result: any, moduleType: \"esm\" | \"commonjs\"]> {\n const tryToImport = async (): Promise<[any, \"esm\"]> => {\n // `Function` is required to make sure the `import` statement wil stay `import` after\n // transpilation and won't be converted to `require`\n return [await Function(\"return filePath => import(filePath)\")()(filePath), \"esm\"];\n };\n const tryToRequire = async (): Promise<[any, \"commonjs\"]> => {\n return [require(filePath), \"commonjs\"];\n };\n\n const extension = filePath.substring(filePath.lastIndexOf(\".\") + \".\".length);\n\n if (extension === \"mjs\" || extension === \"mts\")\n return tryToImport();\n else if (extension === \"cjs\" || extension === \"cts\")\n return tryToRequire();\n else if (extension === \"js\" || extension === \"ts\") {\n const packageJson = await getNearestPackageJson(filePath);\n\n if (packageJson != null) {\n const isModule = (packageJson as any)?.type === \"module\";\n\n if (isModule)\n return tryToImport();\n else\n return tryToRequire();\n } else\n return tryToRequire();\n }\n\n return tryToRequire();\n}\n\nfunction getNearestPackageJson(filePath: string): Promise<object | null> {\n return new Promise((accept) => {\n let currentPath = filePath;\n\n function searchPackageJson() {\n const nextPath = path.dirname(currentPath);\n\n if (currentPath === nextPath) // the top of the file tree is reached\n accept(null);\n else {\n currentPath = nextPath;\n const potentialPackageJson = path.join(currentPath, \"package.json\");\n\n fs.stat(potentialPackageJson, (err, stats) => {\n if (err != null)\n searchPackageJson();\n else if (stats.isFile()) {\n fs.readFile(potentialPackageJson, \"utf8\", (err, data) => {\n if (err != null)\n accept(null);\n else {\n try {\n accept(JSON.parse(data));\n } catch (err) {\n accept(null);\n }\n }\n });\n } else\n searchPackageJson();\n });\n }\n }\n\n searchPackageJson();\n });\n}\n"],"sourceRoot":".."}
|
|
@@ -15,4 +15,8 @@ export declare class CommandUtils {
|
|
|
15
15
|
*/
|
|
16
16
|
static readFile(filePath: string): Promise<string>;
|
|
17
17
|
static fileExists(filePath: string): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Gets migration timestamp and validates argument (if sent)
|
|
20
|
+
*/
|
|
21
|
+
static getTimestamp(timestampOptionArgument: any): number;
|
|
18
22
|
}
|
package/commands/CommandUtils.js
CHANGED
|
@@ -5,6 +5,7 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var fs = (0, tslib_1.__importStar)(require("fs"));
|
|
6
6
|
var path = (0, tslib_1.__importStar)(require("path"));
|
|
7
7
|
var mkdirp_1 = (0, tslib_1.__importDefault)(require("mkdirp"));
|
|
8
|
+
var error_1 = require("../error");
|
|
8
9
|
/**
|
|
9
10
|
* Command line utils functions.
|
|
10
11
|
*/
|
|
@@ -56,6 +57,15 @@ var CommandUtils = /** @class */ (function () {
|
|
|
56
57
|
});
|
|
57
58
|
});
|
|
58
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Gets migration timestamp and validates argument (if sent)
|
|
62
|
+
*/
|
|
63
|
+
CommandUtils.getTimestamp = function (timestampOptionArgument) {
|
|
64
|
+
if (timestampOptionArgument && (isNaN(timestampOptionArgument) || timestampOptionArgument < 0)) {
|
|
65
|
+
throw new error_1.TypeORMError("timestamp option should be a non-negative number. received: " + timestampOptionArgument);
|
|
66
|
+
}
|
|
67
|
+
return timestampOptionArgument ? new Date(Number(timestampOptionArgument)).getTime() : Date.now();
|
|
68
|
+
};
|
|
59
69
|
return CommandUtils;
|
|
60
70
|
}());
|
|
61
71
|
exports.CommandUtils = CommandUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/CommandUtils.ts"],"names":[],"mappings":";;;;AAAA,kDAAyB;AACzB,sDAA6B;AAC7B,+DAA4B;
|
|
1
|
+
{"version":3,"sources":["../../src/commands/CommandUtils.ts"],"names":[],"mappings":";;;;AAAA,kDAAyB;AACzB,sDAA6B;AAC7B,+DAA4B;AAC5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G;IACI,yBAAY,GAAnB,UAAoB,uBAA4B;QAC5C,IAAI,uBAAuB,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,IAAI,uBAAuB,GAAG,CAAC,CAAC,EAAE;YAC5F,MAAM,IAAI,oBAAY,CAAC,iEAA+D,uBAAyB,CAAC,CAAC;SACpH;QACD,OAAO,uBAAuB,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IACtG,CAAC;IACL,mBAAC;AAAD,CA7CA,AA6CC,IAAA;AA7CY,oCAAY","file":"CommandUtils.js","sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\nimport mkdirp from \"mkdirp\";\nimport {TypeORMError} from \"../error\";\n\n/**\n * Command line utils functions.\n */\nexport class CommandUtils {\n\n /**\n * Creates directories recursively.\n */\n static createDirectories(directory: string) {\n return mkdirp(directory);\n }\n\n /**\n * Creates a file with the given content in the given path.\n */\n static async createFile(filePath: string, content: string, override: boolean = true): Promise<void> {\n await CommandUtils.createDirectories(path.dirname(filePath));\n return new Promise<void>((ok, fail) => {\n if (override === false && fs.existsSync(filePath))\n return ok();\n\n fs.writeFile(filePath, content, err => err ? fail(err) : ok());\n });\n }\n\n /**\n * Reads everything from a given file and returns its content as a string.\n */\n static async readFile(filePath: string): Promise<string> {\n return new Promise<string>((ok, fail) => {\n fs.readFile(filePath, (err, data) => err ? fail(err) : ok(data.toString()));\n });\n }\n\n\n static async fileExists(filePath: string) {\n return fs.existsSync(filePath);\n }\n\n /**\n * Gets migration timestamp and validates argument (if sent)\n */\n static getTimestamp(timestampOptionArgument: any): number {\n if (timestampOptionArgument && (isNaN(timestampOptionArgument) || timestampOptionArgument < 0)) {\n throw new TypeORMError(`timestamp option should be a non-negative number. received: ${timestampOptionArgument}`);\n }\n return timestampOptionArgument ? new Date(Number(timestampOptionArgument)).getTime() : Date.now();\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -17,9 +17,11 @@ export declare class InitCommand implements yargs.CommandModule {
|
|
|
17
17
|
docker: unknown;
|
|
18
18
|
} & {
|
|
19
19
|
pm: string;
|
|
20
|
+
} & {
|
|
21
|
+
ms: string;
|
|
20
22
|
}>;
|
|
21
23
|
handler(args: yargs.Arguments): Promise<void>;
|
|
22
|
-
protected static executeCommand(command: string): Promise<string>;
|
|
24
|
+
protected static executeCommand(command: string, cwd: string): Promise<string>;
|
|
23
25
|
/**
|
|
24
26
|
* Gets contents of the ormconfig file.
|
|
25
27
|
*/
|
|
@@ -27,7 +29,7 @@ export declare class InitCommand implements yargs.CommandModule {
|
|
|
27
29
|
/**
|
|
28
30
|
* Gets contents of the ormconfig file.
|
|
29
31
|
*/
|
|
30
|
-
protected static getTsConfigTemplate(): string;
|
|
32
|
+
protected static getTsConfigTemplate(esmModule: boolean): string;
|
|
31
33
|
/**
|
|
32
34
|
* Gets contents of the .gitignore file.
|
|
33
35
|
*/
|
|
@@ -39,19 +41,19 @@ export declare class InitCommand implements yargs.CommandModule {
|
|
|
39
41
|
/**
|
|
40
42
|
* Gets contents of the route file (used when express is enabled).
|
|
41
43
|
*/
|
|
42
|
-
protected static getRoutesTemplate(): string;
|
|
44
|
+
protected static getRoutesTemplate(isEsm: boolean): string;
|
|
43
45
|
/**
|
|
44
46
|
* Gets contents of the user controller file (used when express is enabled).
|
|
45
47
|
*/
|
|
46
|
-
protected static getControllerTemplate(): string;
|
|
48
|
+
protected static getControllerTemplate(isEsm: boolean): string;
|
|
47
49
|
/**
|
|
48
50
|
* Gets contents of the main (index) application file.
|
|
49
51
|
*/
|
|
50
|
-
protected static getAppIndexTemplate(express: boolean): string;
|
|
52
|
+
protected static getAppIndexTemplate(express: boolean, isEsm: boolean): string;
|
|
51
53
|
/**
|
|
52
54
|
* Gets contents of the new package.json file.
|
|
53
55
|
*/
|
|
54
|
-
protected static getPackageJsonTemplate(projectName?: string): string;
|
|
56
|
+
protected static getPackageJsonTemplate(projectName?: string, projectIsEsm?: boolean): string;
|
|
55
57
|
/**
|
|
56
58
|
* Gets contents of the new docker-compose.yml file.
|
|
57
59
|
*/
|
|
@@ -65,5 +67,5 @@ export declare class InitCommand implements yargs.CommandModule {
|
|
|
65
67
|
/**
|
|
66
68
|
* Appends to a given package.json template everything needed.
|
|
67
69
|
*/
|
|
68
|
-
protected static appendPackageJson(packageJsonContents: string, database: string, express: boolean): string;
|
|
70
|
+
protected static appendPackageJson(packageJsonContents: string, database: string, express: boolean, projectIsEsm: boolean): string;
|
|
69
71
|
}
|
package/commands/InitCommand.js
CHANGED
|
@@ -43,11 +43,17 @@ var InitCommand = /** @class */ (function () {
|
|
|
43
43
|
choices: ["npm", "yarn"],
|
|
44
44
|
default: "npm",
|
|
45
45
|
describe: "Install packages, expected values are npm or yarn."
|
|
46
|
+
})
|
|
47
|
+
.option("ms", {
|
|
48
|
+
alias: "module",
|
|
49
|
+
choices: ["commonjs", "esm"],
|
|
50
|
+
default: "commonjs",
|
|
51
|
+
describe: "Module system to use for project, expected values are commonjs or esm."
|
|
46
52
|
});
|
|
47
53
|
};
|
|
48
54
|
InitCommand.prototype.handler = function (args) {
|
|
49
55
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
50
|
-
var database, isExpress, isDocker, basePath, projectName, installNpm, packageJsonContents, err_1;
|
|
56
|
+
var database, isExpress, isDocker, basePath, projectName, installNpm, projectIsEsm, packageJsonContents, err_1;
|
|
51
57
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
52
58
|
switch (_a.label) {
|
|
53
59
|
case 0:
|
|
@@ -58,7 +64,8 @@ var InitCommand = /** @class */ (function () {
|
|
|
58
64
|
basePath = process.cwd() + (args.name ? ("/" + args.name) : "");
|
|
59
65
|
projectName = args.name ? path.basename(args.name) : undefined;
|
|
60
66
|
installNpm = args.pm === "yarn" ? false : true;
|
|
61
|
-
|
|
67
|
+
projectIsEsm = args.ms === "esm";
|
|
68
|
+
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/package.json", InitCommand.getPackageJsonTemplate(projectName, projectIsEsm), false)];
|
|
62
69
|
case 1:
|
|
63
70
|
_a.sent();
|
|
64
71
|
if (!isDocker) return [3 /*break*/, 3];
|
|
@@ -72,7 +79,7 @@ var InitCommand = /** @class */ (function () {
|
|
|
72
79
|
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/README.md", InitCommand.getReadmeTemplate({ docker: isDocker }), false)];
|
|
73
80
|
case 5:
|
|
74
81
|
_a.sent();
|
|
75
|
-
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/tsconfig.json", InitCommand.getTsConfigTemplate())];
|
|
82
|
+
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/tsconfig.json", InitCommand.getTsConfigTemplate(projectIsEsm))];
|
|
76
83
|
case 6:
|
|
77
84
|
_a.sent();
|
|
78
85
|
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/ormconfig.json", InitCommand.getOrmConfigTemplate(database))];
|
|
@@ -81,24 +88,24 @@ var InitCommand = /** @class */ (function () {
|
|
|
81
88
|
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/src/entity/User.ts", InitCommand.getUserEntityTemplate(database))];
|
|
82
89
|
case 8:
|
|
83
90
|
_a.sent();
|
|
84
|
-
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/src/index.ts", InitCommand.getAppIndexTemplate(isExpress))];
|
|
91
|
+
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/src/index.ts", InitCommand.getAppIndexTemplate(isExpress, projectIsEsm))];
|
|
85
92
|
case 9:
|
|
86
93
|
_a.sent();
|
|
87
94
|
return [4 /*yield*/, CommandUtils_1.CommandUtils.createDirectories(basePath + "/src/migration")];
|
|
88
95
|
case 10:
|
|
89
96
|
_a.sent();
|
|
90
97
|
if (!isExpress) return [3 /*break*/, 13];
|
|
91
|
-
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/src/routes.ts", InitCommand.getRoutesTemplate())];
|
|
98
|
+
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/src/routes.ts", InitCommand.getRoutesTemplate(projectIsEsm))];
|
|
92
99
|
case 11:
|
|
93
100
|
_a.sent();
|
|
94
|
-
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/src/controller/UserController.ts", InitCommand.getControllerTemplate())];
|
|
101
|
+
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/src/controller/UserController.ts", InitCommand.getControllerTemplate(projectIsEsm))];
|
|
95
102
|
case 12:
|
|
96
103
|
_a.sent();
|
|
97
104
|
_a.label = 13;
|
|
98
105
|
case 13: return [4 /*yield*/, CommandUtils_1.CommandUtils.readFile(basePath + "/package.json")];
|
|
99
106
|
case 14:
|
|
100
107
|
packageJsonContents = _a.sent();
|
|
101
|
-
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/package.json", InitCommand.appendPackageJson(packageJsonContents, database, isExpress))];
|
|
108
|
+
return [4 /*yield*/, CommandUtils_1.CommandUtils.createFile(basePath + "/package.json", InitCommand.appendPackageJson(packageJsonContents, database, isExpress, projectIsEsm))];
|
|
102
109
|
case 15:
|
|
103
110
|
_a.sent();
|
|
104
111
|
if (args.name) {
|
|
@@ -108,11 +115,11 @@ var InitCommand = /** @class */ (function () {
|
|
|
108
115
|
console.log(chalk_1.default.green("Project created inside current directory."));
|
|
109
116
|
}
|
|
110
117
|
if (!(args.pm && installNpm)) return [3 /*break*/, 17];
|
|
111
|
-
return [4 /*yield*/, InitCommand.executeCommand("npm install")];
|
|
118
|
+
return [4 /*yield*/, InitCommand.executeCommand("npm install", basePath)];
|
|
112
119
|
case 16:
|
|
113
120
|
_a.sent();
|
|
114
121
|
return [3 /*break*/, 19];
|
|
115
|
-
case 17: return [4 /*yield*/, InitCommand.executeCommand("yarn install")];
|
|
122
|
+
case 17: return [4 /*yield*/, InitCommand.executeCommand("yarn install", basePath)];
|
|
116
123
|
case 18:
|
|
117
124
|
_a.sent();
|
|
118
125
|
_a.label = 19;
|
|
@@ -131,9 +138,9 @@ var InitCommand = /** @class */ (function () {
|
|
|
131
138
|
// -------------------------------------------------------------------------
|
|
132
139
|
// Protected Static Methods
|
|
133
140
|
// -------------------------------------------------------------------------
|
|
134
|
-
InitCommand.executeCommand = function (command) {
|
|
141
|
+
InitCommand.executeCommand = function (command, cwd) {
|
|
135
142
|
return new Promise(function (ok, fail) {
|
|
136
|
-
(0, child_process_1.exec)(command, function (error, stdout, stderr) {
|
|
143
|
+
(0, child_process_1.exec)(command, { cwd: cwd }, function (error, stdout, stderr) {
|
|
137
144
|
if (stdout)
|
|
138
145
|
return ok(stdout);
|
|
139
146
|
if (stderr)
|
|
@@ -251,19 +258,34 @@ var InitCommand = /** @class */ (function () {
|
|
|
251
258
|
/**
|
|
252
259
|
* Gets contents of the ormconfig file.
|
|
253
260
|
*/
|
|
254
|
-
InitCommand.getTsConfigTemplate = function () {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
261
|
+
InitCommand.getTsConfigTemplate = function (esmModule) {
|
|
262
|
+
if (esmModule)
|
|
263
|
+
return JSON.stringify({
|
|
264
|
+
compilerOptions: {
|
|
265
|
+
lib: ["es2021"],
|
|
266
|
+
target: "es2021",
|
|
267
|
+
module: "es2022",
|
|
268
|
+
moduleResolution: "node",
|
|
269
|
+
allowSyntheticDefaultImports: true,
|
|
270
|
+
outDir: "./build",
|
|
271
|
+
emitDecoratorMetadata: true,
|
|
272
|
+
experimentalDecorators: true,
|
|
273
|
+
sourceMap: true
|
|
274
|
+
}
|
|
275
|
+
}, undefined, 3);
|
|
276
|
+
else
|
|
277
|
+
return JSON.stringify({
|
|
278
|
+
compilerOptions: {
|
|
279
|
+
lib: ["es5", "es6"],
|
|
280
|
+
target: "es5",
|
|
281
|
+
module: "commonjs",
|
|
282
|
+
moduleResolution: "node",
|
|
283
|
+
outDir: "./build",
|
|
284
|
+
emitDecoratorMetadata: true,
|
|
285
|
+
experimentalDecorators: true,
|
|
286
|
+
sourceMap: true
|
|
287
|
+
}
|
|
288
|
+
}, undefined, 3);
|
|
267
289
|
};
|
|
268
290
|
/**
|
|
269
291
|
* Gets contents of the .gitignore file.
|
|
@@ -280,34 +302,35 @@ var InitCommand = /** @class */ (function () {
|
|
|
280
302
|
/**
|
|
281
303
|
* Gets contents of the route file (used when express is enabled).
|
|
282
304
|
*/
|
|
283
|
-
InitCommand.getRoutesTemplate = function () {
|
|
284
|
-
return "import {UserController} from \"./controller/UserController\";\n\nexport const Routes = [{\n method: \"get\",\n route: \"/users\",\n controller: UserController,\n action: \"all\"\n}, {\n method: \"get\",\n route: \"/users/:id\",\n controller: UserController,\n action: \"one\"\n}, {\n method: \"post\",\n route: \"/users\",\n controller: UserController,\n action: \"save\"\n}, {\n method: \"delete\",\n route: \"/users/:id\",\n controller: UserController,\n action: \"remove\"\n}];";
|
|
305
|
+
InitCommand.getRoutesTemplate = function (isEsm) {
|
|
306
|
+
return "import {UserController} from \"./controller/UserController" + (isEsm ? ".js" : "") + "\";\n\nexport const Routes = [{\n method: \"get\",\n route: \"/users\",\n controller: UserController,\n action: \"all\"\n}, {\n method: \"get\",\n route: \"/users/:id\",\n controller: UserController,\n action: \"one\"\n}, {\n method: \"post\",\n route: \"/users\",\n controller: UserController,\n action: \"save\"\n}, {\n method: \"delete\",\n route: \"/users/:id\",\n controller: UserController,\n action: \"remove\"\n}];";
|
|
285
307
|
};
|
|
286
308
|
/**
|
|
287
309
|
* Gets contents of the user controller file (used when express is enabled).
|
|
288
310
|
*/
|
|
289
|
-
InitCommand.getControllerTemplate = function () {
|
|
290
|
-
return "import {getRepository} from \"typeorm\";\nimport {NextFunction, Request, Response} from \"express\";\nimport {User} from \"../entity/User\";\n\nexport class UserController {\n\n private userRepository = getRepository(User);\n\n async all(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.find();\n }\n\n async one(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.findOne(request.params.id);\n }\n\n async save(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.save(request.body);\n }\n\n async remove(request: Request, response: Response, next: NextFunction) {\n let userToRemove = await this.userRepository.findOne(request.params.id);\n await this.userRepository.remove(userToRemove);\n }\n\n}";
|
|
311
|
+
InitCommand.getControllerTemplate = function (isEsm) {
|
|
312
|
+
return "import {getRepository} from \"typeorm\";\nimport {NextFunction, Request, Response} from \"express\";\nimport {User} from \"../entity/User" + (isEsm ? ".js" : "") + "\";\n\nexport class UserController {\n\n private userRepository = getRepository(User);\n\n async all(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.find();\n }\n\n async one(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.findOne(request.params.id);\n }\n\n async save(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.save(request.body);\n }\n\n async remove(request: Request, response: Response, next: NextFunction) {\n let userToRemove = await this.userRepository.findOne(request.params.id);\n await this.userRepository.remove(userToRemove);\n }\n\n}";
|
|
291
313
|
};
|
|
292
314
|
/**
|
|
293
315
|
* Gets contents of the main (index) application file.
|
|
294
316
|
*/
|
|
295
|
-
InitCommand.getAppIndexTemplate = function (express) {
|
|
317
|
+
InitCommand.getAppIndexTemplate = function (express, isEsm) {
|
|
296
318
|
if (express) {
|
|
297
|
-
return "import \"reflect-metadata\";\nimport {createConnection} from \"typeorm\";\nimport * as express from \"express\";\nimport * as bodyParser from \"body-parser\";\nimport {Request, Response} from \"express\";\nimport {Routes} from \"./routes\";\nimport {User} from \"./entity/User\";\n\ncreateConnection().then(async connection => {\n\n // create express app\n const app = express();\n app.use(bodyParser.json());\n\n // register express routes from defined application routes\n Routes.forEach(route => {\n (app as any)[route.method](route.route, (req: Request, res: Response, next: Function) => {\n const result = (new (route.controller as any))[route.action](req, res, next);\n if (result instanceof Promise) {\n result.then(result => result !== null && result !== undefined ? res.send(result) : undefined);\n\n } else if (result !== null && result !== undefined) {\n res.json(result);\n }\n });\n });\n\n // setup express app here\n // ...\n\n // start express server\n app.listen(3000);\n\n // insert new users for test\n await connection.manager.save(connection.manager.create(User, {\n firstName: \"Timber\",\n lastName: \"Saw\",\n age: 27\n }));\n await connection.manager.save(connection.manager.create(User, {\n firstName: \"Phantom\",\n lastName: \"Assassin\",\n age: 24\n }));\n\n console.log(\"Express server has started on port 3000. Open http://localhost:3000/users to see results\");\n\n}).catch(error => console.log(error));\n";
|
|
319
|
+
return "import \"reflect-metadata\";\nimport {createConnection} from \"typeorm\";\nimport " + (!isEsm ? "* as " : "") + "express from \"express\";\nimport " + (!isEsm ? "* as " : "") + "bodyParser from \"body-parser\";\nimport {Request, Response} from \"express\";\nimport {Routes} from \"./routes" + (isEsm ? ".js" : "") + "\";\nimport {User} from \"./entity/User" + (isEsm ? ".js" : "") + "\";\n\ncreateConnection().then(async connection => {\n\n // create express app\n const app = express();\n app.use(bodyParser.json());\n\n // register express routes from defined application routes\n Routes.forEach(route => {\n (app as any)[route.method](route.route, (req: Request, res: Response, next: Function) => {\n const result = (new (route.controller as any))[route.action](req, res, next);\n if (result instanceof Promise) {\n result.then(result => result !== null && result !== undefined ? res.send(result) : undefined);\n\n } else if (result !== null && result !== undefined) {\n res.json(result);\n }\n });\n });\n\n // setup express app here\n // ...\n\n // start express server\n app.listen(3000);\n\n // insert new users for test\n await connection.manager.save(connection.manager.create(User, {\n firstName: \"Timber\",\n lastName: \"Saw\",\n age: 27\n }));\n await connection.manager.save(connection.manager.create(User, {\n firstName: \"Phantom\",\n lastName: \"Assassin\",\n age: 24\n }));\n\n console.log(\"Express server has started on port 3000. Open http://localhost:3000/users to see results\");\n\n}).catch(error => console.log(error));\n";
|
|
298
320
|
}
|
|
299
321
|
else {
|
|
300
|
-
return "import \"reflect-metadata\";\nimport {createConnection} from \"typeorm\";\nimport {User} from \"./entity/User\";\n\ncreateConnection().then(async connection => {\n\n console.log(\"Inserting a new user into the database...\");\n const user = new User();\n user.firstName = \"Timber\";\n user.lastName = \"Saw\";\n user.age = 25;\n await connection.manager.save(user);\n console.log(\"Saved a new user with id: \" + user.id);\n\n console.log(\"Loading users from the database...\");\n const users = await connection.manager.find(User);\n console.log(\"Loaded users: \", users);\n\n console.log(\"Here you can setup and run express/koa/any other framework.\");\n\n}).catch(error => console.log(error));\n";
|
|
322
|
+
return "import \"reflect-metadata\";\nimport {createConnection} from \"typeorm\";\nimport {User} from \"./entity/User" + (isEsm ? ".js" : "") + "\";\n\ncreateConnection().then(async connection => {\n\n console.log(\"Inserting a new user into the database...\");\n const user = new User();\n user.firstName = \"Timber\";\n user.lastName = \"Saw\";\n user.age = 25;\n await connection.manager.save(user);\n console.log(\"Saved a new user with id: \" + user.id);\n\n console.log(\"Loading users from the database...\");\n const users = await connection.manager.find(User);\n console.log(\"Loaded users: \", users);\n\n console.log(\"Here you can setup and run express/koa/any other framework.\");\n\n}).catch(error => console.log(error));\n";
|
|
301
323
|
}
|
|
302
324
|
};
|
|
303
325
|
/**
|
|
304
326
|
* Gets contents of the new package.json file.
|
|
305
327
|
*/
|
|
306
|
-
InitCommand.getPackageJsonTemplate = function (projectName) {
|
|
328
|
+
InitCommand.getPackageJsonTemplate = function (projectName, projectIsEsm) {
|
|
307
329
|
return JSON.stringify({
|
|
308
330
|
name: projectName || "new-typeorm-project",
|
|
309
331
|
version: "0.0.1",
|
|
310
332
|
description: "Awesome project developed with TypeORM.",
|
|
333
|
+
type: projectIsEsm ? "module" : "commonjs",
|
|
311
334
|
devDependencies: {},
|
|
312
335
|
dependencies: {},
|
|
313
336
|
scripts: {}
|
|
@@ -355,20 +378,20 @@ var InitCommand = /** @class */ (function () {
|
|
|
355
378
|
/**
|
|
356
379
|
* Appends to a given package.json template everything needed.
|
|
357
380
|
*/
|
|
358
|
-
InitCommand.appendPackageJson = function (packageJsonContents, database, express /*, docker: boolean*/) {
|
|
381
|
+
InitCommand.appendPackageJson = function (packageJsonContents, database, express, projectIsEsm /*, docker: boolean*/) {
|
|
359
382
|
var packageJson = JSON.parse(packageJsonContents);
|
|
360
383
|
if (!packageJson.devDependencies)
|
|
361
384
|
packageJson.devDependencies = {};
|
|
362
385
|
Object.assign(packageJson.devDependencies, {
|
|
363
|
-
"ts-node": "
|
|
364
|
-
"@types/node": "^
|
|
365
|
-
"typescript": "
|
|
386
|
+
"ts-node": "10.4.0",
|
|
387
|
+
"@types/node": "^16.11.10",
|
|
388
|
+
"typescript": "4.5.2"
|
|
366
389
|
});
|
|
367
390
|
if (!packageJson.dependencies)
|
|
368
391
|
packageJson.dependencies = {};
|
|
369
392
|
Object.assign(packageJson.dependencies, {
|
|
370
393
|
"typeorm": require("../package.json").version,
|
|
371
|
-
"reflect-metadata": "^0.1.
|
|
394
|
+
"reflect-metadata": "^0.1.13"
|
|
372
395
|
});
|
|
373
396
|
switch (database) {
|
|
374
397
|
case "mysql":
|
|
@@ -396,15 +419,21 @@ var InitCommand = /** @class */ (function () {
|
|
|
396
419
|
break;
|
|
397
420
|
}
|
|
398
421
|
if (express) {
|
|
399
|
-
packageJson.dependencies["express"] = "^4.
|
|
400
|
-
packageJson.dependencies["body-parser"] = "^1.
|
|
422
|
+
packageJson.dependencies["express"] = "^4.17.2";
|
|
423
|
+
packageJson.dependencies["body-parser"] = "^1.19.1";
|
|
401
424
|
}
|
|
402
425
|
if (!packageJson.scripts)
|
|
403
426
|
packageJson.scripts = {};
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
427
|
+
if (projectIsEsm)
|
|
428
|
+
Object.assign(packageJson.scripts, {
|
|
429
|
+
start: /*(docker ? "docker-compose up && " : "") + */ "node --loader ts-node/esm src/index.ts",
|
|
430
|
+
typeorm: "node --loader ts-node/esm ./node_modules/typeorm/cli.js"
|
|
431
|
+
});
|
|
432
|
+
else
|
|
433
|
+
Object.assign(packageJson.scripts, {
|
|
434
|
+
start: /*(docker ? "docker-compose up && " : "") + */ "ts-node src/index.ts",
|
|
435
|
+
typeorm: "node --require ts-node/register ./node_modules/typeorm/cli.js"
|
|
436
|
+
});
|
|
408
437
|
return JSON.stringify(packageJson, undefined, 3);
|
|
409
438
|
};
|
|
410
439
|
return InitCommand;
|