miqro 2.0.2 → 3.0.1
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 +18 -36
- package/build/cli.js +6 -0
- package/build/cmd-map.d.ts +79 -0
- package/{dist/cli.js → build/cmd-map.js} +22 -49
- package/{dist → build}/cmds/doc-json.d.ts +1 -1
- package/{dist → build}/cmds/doc-json.js +3 -3
- package/build/cmds/doc-md.d.ts +2 -0
- package/build/cmds/doc-md.js +17 -0
- package/{dist → build}/cmds/handler-main-new.js +23 -15
- package/build/cmds/help.d.ts +1 -0
- package/build/cmds/help.js +9 -0
- package/{dist → build}/cmds/new-test.js +13 -2
- package/{dist → build}/cmds/new.js +20 -15
- package/{dist → build}/cmds/serve.d.ts +1 -1
- package/{dist → build}/cmds/serve.js +12 -7
- package/build/utils/doc/json.d.ts +6 -0
- package/{dist/utils/doc/index.js → build/utils/doc/json.js} +2 -3
- package/build/utils/doc/md.d.ts +18 -0
- package/build/utils/doc/md.js +129 -0
- package/{dist → build}/utils/index.d.ts +7 -4
- package/{dist → build}/utils/index.js +20 -14
- package/package.json +13 -14
- package/dist/cmds/db-console.d.ts +0 -2
- package/dist/cmds/db-console.js +0 -38
- package/dist/cmds/db-createmodel.d.ts +0 -2
- package/dist/cmds/db-createmodel.js +0 -37
- package/dist/cmds/db-dump-data.d.ts +0 -2
- package/dist/cmds/db-dump-data.js +0 -43
- package/dist/cmds/db-init.d.ts +0 -2
- package/dist/cmds/db-init.js +0 -38
- package/dist/cmds/db-makemigrations.d.ts +0 -2
- package/dist/cmds/db-makemigrations.js +0 -14
- package/dist/cmds/db-migrate.d.ts +0 -2
- package/dist/cmds/db-migrate.js +0 -12
- package/dist/cmds/db-push-data.d.ts +0 -2
- package/dist/cmds/db-push-data.js +0 -79
- package/dist/cmds/db-sync-makemigrations.d.ts +0 -2
- package/dist/cmds/db-sync-makemigrations.js +0 -14
- package/dist/cmds/test.d.ts +0 -2
- package/dist/cmds/test.js +0 -15
- package/dist/utils/db/automigrations/index.d.ts +0 -2
- package/dist/utils/db/automigrations/index.js +0 -121
- package/dist/utils/db/automigrations/migrate.d.ts +0 -45
- package/dist/utils/db/automigrations/migrate.js +0 -750
- package/dist/utils/db/index.d.ts +0 -20
- package/dist/utils/db/index.js +0 -127
- package/dist/utils/doc/index.d.ts +0 -7
- /package/{dist → build}/cli.d.ts +0 -0
- /package/{dist → build}/cmds/config-bash.d.ts +0 -0
- /package/{dist → build}/cmds/config-bash.js +0 -0
- /package/{dist → build}/cmds/config-env.d.ts +0 -0
- /package/{dist → build}/cmds/config-env.js +0 -0
- /package/{dist → build}/cmds/config-init.d.ts +0 -0
- /package/{dist → build}/cmds/config-init.js +0 -0
- /package/{dist → build}/cmds/config.d.ts +0 -0
- /package/{dist → build}/cmds/config.js +0 -0
- /package/{dist → build}/cmds/handler-apiroute-new.d.ts +0 -0
- /package/{dist → build}/cmds/handler-apiroute-new.js +0 -0
- /package/{dist → build}/cmds/handler-main-new.d.ts +0 -0
- /package/{dist → build}/cmds/new-test.d.ts +0 -0
- /package/{dist → build}/cmds/new.d.ts +0 -0
- /package/{dist → build}/cmds/start.d.ts +0 -0
- /package/{dist → build}/cmds/start.js +0 -0
- /package/{dist → build}/cmds/watch.d.ts +0 -0
- /package/{dist → build}/cmds/watch.js +0 -0
- /package/{dist → build}/cmds/wc-new.d.ts +0 -0
- /package/{dist → build}/cmds/wc-new.js +0 -0
- /package/{dist → build}/index.d.ts +0 -0
- /package/{dist → build}/index.js +0 -0
- /package/{dist → build}/utils/templates.d.ts +0 -0
- /package/{dist → build}/utils/templates.js +0 -0
package/dist/utils/db/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Logger } from "@miqro/core";
|
|
2
|
-
export interface SequelizeRC {
|
|
3
|
-
config: string;
|
|
4
|
-
"migrations-path": string;
|
|
5
|
-
"seeders-path": string;
|
|
6
|
-
"models-path": string;
|
|
7
|
-
}
|
|
8
|
-
export declare const loadSequelizeRC: (sequelizercPath?: string, logger?: Logger) => SequelizeRC;
|
|
9
|
-
export declare const loadModels: (args?: {
|
|
10
|
-
"models-path": string;
|
|
11
|
-
}) => {
|
|
12
|
-
path: string;
|
|
13
|
-
modelsModule: any;
|
|
14
|
-
};
|
|
15
|
-
export declare const loadSequelize: (args?: {
|
|
16
|
-
"models-path": string;
|
|
17
|
-
}, l?: Logger) => any;
|
|
18
|
-
export declare const initDBConfig: () => boolean;
|
|
19
|
-
export declare const makemigrations: () => void;
|
|
20
|
-
export declare const syncMakeMigrations: () => void;
|
package/dist/utils/db/index.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.syncMakeMigrations = exports.makemigrations = exports.initDBConfig = exports.loadSequelize = exports.loadModels = exports.loadSequelizeRC = void 0;
|
|
4
|
-
const automigrations_1 = require("./automigrations");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const templates_1 = require("../../utils/templates");
|
|
8
|
-
const core_1 = require("@miqro/core");
|
|
9
|
-
const parser_1 = require("@miqro/parser");
|
|
10
|
-
const logger = console;
|
|
11
|
-
const loadSequelizeRC = (sequelizercPath = core_1.ConfigPathResolver.getSequelizeRCFilePath(), logger) => {
|
|
12
|
-
// noinspection SpellCheckingInspection
|
|
13
|
-
if (!(0, fs_1.existsSync)(sequelizercPath)) {
|
|
14
|
-
// noinspection SpellCheckingInspection
|
|
15
|
-
throw new core_1.ConfigFileNotFoundError(`missing ${sequelizercPath} file. maybe you didnt init your db config.`);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
if (logger) {
|
|
19
|
-
logger.debug(`loading sequelize config from [${sequelizercPath}]`);
|
|
20
|
-
}
|
|
21
|
-
// noinspection SpellCheckingInspection
|
|
22
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
23
|
-
const sequelizerc = require(sequelizercPath);
|
|
24
|
-
return (0, parser_1.parse)(sequelizerc, {
|
|
25
|
-
config: "string",
|
|
26
|
-
"migrations-path": "string",
|
|
27
|
-
"seeders-path": "string",
|
|
28
|
-
"models-path": "string"
|
|
29
|
-
}, "no_extra", sequelizercPath);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
exports.loadSequelizeRC = loadSequelizeRC;
|
|
33
|
-
const loadModels = (args) => {
|
|
34
|
-
const sequelizerc = args ? args : (0, exports.loadSequelizeRC)();
|
|
35
|
-
const modelsModule = require(sequelizerc["models-path"]);
|
|
36
|
-
return {
|
|
37
|
-
path: sequelizerc["models-path"],
|
|
38
|
-
modelsModule
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
exports.loadModels = loadModels;
|
|
42
|
-
const loadSequelize = (args, l) => {
|
|
43
|
-
const logger = l ? l : (0, core_1.getLogger)("Database");
|
|
44
|
-
const { modelsModule, path } = (0, exports.loadModels)();
|
|
45
|
-
if (!modelsModule.sequelize || typeof modelsModule.sequelize !== "object" || typeof modelsModule.sequelize.models !== "object") {
|
|
46
|
-
throw new Error(`${path} doesnt export sequelize`);
|
|
47
|
-
}
|
|
48
|
-
modelsModule.sequelize.log = (text) => {
|
|
49
|
-
logger.info(text);
|
|
50
|
-
};
|
|
51
|
-
return modelsModule.sequelize;
|
|
52
|
-
};
|
|
53
|
-
exports.loadSequelize = loadSequelize;
|
|
54
|
-
// noinspection SpellCheckingInspection
|
|
55
|
-
const initDBConfig = () => {
|
|
56
|
-
try {
|
|
57
|
-
const initDir = (p) => {
|
|
58
|
-
if (!(0, fs_1.existsSync)(p)) {
|
|
59
|
-
logger.warn(`creating ${p}`);
|
|
60
|
-
(0, fs_1.mkdirSync)(p);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
logger.warn(`${p} already exists!. init will not create it.`);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const initFile = (p, template) => {
|
|
67
|
-
if (!(0, fs_1.existsSync)(p)) {
|
|
68
|
-
logger.warn(`creating ${p} file`);
|
|
69
|
-
(0, fs_1.writeFileSync)(p, template);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
logger.warn(`${p} already exists!. init will not create it.`);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
// noinspection SpellCheckingInspection
|
|
76
|
-
const sequelizercPath = (0, path_1.resolve)(core_1.ConfigPathResolver.getBaseDirname(), ".sequelizerc");
|
|
77
|
-
if ((0, fs_1.existsSync)(sequelizercPath)) {
|
|
78
|
-
logger.warn(`.sequelizerc already exists!. init will do nothing.`);
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
// disable experimental typescript support
|
|
83
|
-
const typescript = false; //existsSync(resolve(ConfigPathResolver.getBaseDirname(), "tsconfig.json")) ? true : false;
|
|
84
|
-
const dbFolder = (0, path_1.resolve)(core_1.ConfigPathResolver.getBaseDirname(), "db");
|
|
85
|
-
const migrationsFolder = (0, path_1.resolve)(dbFolder, "migrations");
|
|
86
|
-
const modelsFolder = typescript ? (0, path_1.resolve)("src", "models") : (0, path_1.resolve)(dbFolder, "models");
|
|
87
|
-
const seedersFolder = (0, path_1.resolve)(dbFolder, "seeders");
|
|
88
|
-
const modelLoaderPath = (0, path_1.resolve)(modelsFolder, typescript ? "index.ts" : "index.js");
|
|
89
|
-
const dbConfigFilePath = (0, path_1.resolve)(dbFolder, "connection.js");
|
|
90
|
-
// noinspection SpellCheckingInspection
|
|
91
|
-
initFile(sequelizercPath, templates_1.templates.sequelizerc(typescript));
|
|
92
|
-
initDir(dbFolder);
|
|
93
|
-
initFile(dbConfigFilePath, templates_1.templates.dbConfig);
|
|
94
|
-
initDir(migrationsFolder);
|
|
95
|
-
initDir(modelsFolder);
|
|
96
|
-
initFile(modelLoaderPath, templates_1.templates.modelsIndex);
|
|
97
|
-
initDir(seedersFolder);
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
catch (e) {
|
|
102
|
-
logger.error(e.message);
|
|
103
|
-
throw e;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
exports.initDBConfig = initDBConfig;
|
|
107
|
-
// noinspection SpellCheckingInspection
|
|
108
|
-
const makemigrations = () => {
|
|
109
|
-
try {
|
|
110
|
-
(0, automigrations_1.makemigrationsImpl)();
|
|
111
|
-
}
|
|
112
|
-
catch (e) {
|
|
113
|
-
logger.error(e.message);
|
|
114
|
-
throw e;
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
exports.makemigrations = makemigrations;
|
|
118
|
-
const syncMakeMigrations = () => {
|
|
119
|
-
try {
|
|
120
|
-
(0, automigrations_1.syncMakeMigrationsImpl)();
|
|
121
|
-
}
|
|
122
|
-
catch (e) {
|
|
123
|
-
logger.error(e.message);
|
|
124
|
-
throw e;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
exports.syncMakeMigrations = syncMakeMigrations;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Logger } from "@miqro/core";
|
|
2
|
-
import { RouterJSONDoc } from "@miqro/core/dist/common/router-utils";
|
|
3
|
-
export declare const getDOCJSON: ({ dirname, subPath, apiName }: {
|
|
4
|
-
apiName?: string | undefined;
|
|
5
|
-
dirname: string;
|
|
6
|
-
subPath: string;
|
|
7
|
-
}, logger: Logger) => RouterJSONDoc;
|
/package/{dist → build}/cli.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{dist → build}/index.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|