@rws-framework/db 2.4.5 → 3.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/.bin/add-v.sh +9 -9
- package/.bin/emerge.sh +10 -10
- package/.eslintrc.json +53 -53
- package/README.md +404 -404
- package/dist/decorators/IdType.d.ts +8 -0
- package/dist/decorators/IdType.js +10 -0
- package/dist/decorators/InverseRelation.d.ts +2 -2
- package/dist/decorators/InverseRelation.js +5 -1
- package/dist/decorators/InverseTimeSeries.d.ts +0 -0
- package/dist/decorators/InverseTimeSeries.js +0 -0
- package/dist/decorators/RWSCollection.d.ts +7 -0
- package/dist/decorators/RWSCollection.js +6 -0
- package/dist/decorators/Relation.d.ts +8 -6
- package/dist/decorators/Relation.js +8 -1
- package/dist/decorators/TrackType.d.ts +2 -14
- package/dist/decorators/TrackType.js +7 -0
- package/dist/decorators/TypeFunctions.d.ts +44 -0
- package/dist/decorators/TypeFunctions.js +174 -0
- package/dist/decorators/index.d.ts +4 -2
- package/dist/decorators/index.js +3 -1
- package/dist/helper/DbHelper.d.ts +76 -5
- package/dist/helper/DbHelper.js +93 -154
- package/dist/helper/FieldsHelper.d.ts +0 -0
- package/dist/helper/FieldsHelper.js +0 -0
- package/dist/helper/db/index.d.ts +9 -0
- package/dist/helper/db/index.js +18 -0
- package/dist/helper/db/relation-manager.d.ts +45 -0
- package/dist/helper/db/relation-manager.js +105 -0
- package/dist/helper/db/schema-generator.d.ts +37 -0
- package/dist/helper/db/schema-generator.js +243 -0
- package/dist/helper/db/type-converter.d.ts +22 -0
- package/dist/helper/db/type-converter.js +106 -0
- package/dist/helper/db/utils.d.ts +24 -0
- package/dist/helper/db/utils.js +99 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -1
- package/dist/models/TimeSeriesModel.d.ts +7 -7
- package/dist/models/TimeSeriesModel.js +33 -33
- package/dist/models/_model.d.ts +2 -2
- package/dist/models/_model.js +0 -0
- package/dist/models/core/RWSModel.d.ts +4 -1
- package/dist/models/core/RWSModel.js +6 -4
- package/dist/models/core/TimeSeriesModel.d.ts +0 -0
- package/dist/models/core/TimeSeriesModel.js +0 -0
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.js +0 -0
- package/dist/models/interfaces/IDbOpts.d.ts +17 -0
- package/dist/models/interfaces/IDbOpts.js +2 -0
- package/dist/models/interfaces/IIdOpts.d.ts +0 -0
- package/dist/models/interfaces/IIdOpts.js +1 -0
- package/dist/models/interfaces/IIdTypeOpts.d.ts +3 -0
- package/dist/models/interfaces/IIdTypeOpts.js +2 -0
- package/dist/models/interfaces/IModel.d.ts +0 -0
- package/dist/models/interfaces/IModel.js +0 -0
- package/dist/models/interfaces/IRWSModelServices.d.ts +0 -0
- package/dist/models/interfaces/IRWSModelServices.js +0 -0
- package/dist/models/interfaces/ITrackerOpts.d.ts +12 -0
- package/dist/models/interfaces/ITrackerOpts.js +2 -0
- package/dist/models/interfaces/OpModelType.d.ts +3 -0
- package/dist/models/interfaces/OpModelType.js +0 -0
- package/dist/models/types/RelationTypes.d.ts +0 -0
- package/dist/models/types/RelationTypes.js +0 -0
- package/dist/models/utils/ModelUtils.d.ts +0 -0
- package/dist/models/utils/ModelUtils.js +0 -0
- package/dist/models/utils/PaginationUtils.d.ts +0 -0
- package/dist/models/utils/PaginationUtils.js +0 -0
- package/dist/models/utils/RelationUtils.d.ts +1 -1
- package/dist/models/utils/RelationUtils.js +2 -2
- package/dist/models/utils/TimeSeriesUtils.d.ts +0 -0
- package/dist/models/utils/TimeSeriesUtils.js +0 -0
- package/dist/services/DBService.d.ts +0 -0
- package/dist/services/DBService.js +0 -0
- package/dist/types/DbConfigHandler.d.ts +1 -1
- package/dist/types/DbConfigHandler.js +0 -0
- package/dist/types/FindParams.d.ts +0 -0
- package/dist/types/FindParams.js +0 -0
- package/dist/types/IRWSModel.d.ts +1 -1
- package/dist/types/IRWSModel.js +0 -0
- package/dist/types/ITimeSeries.d.ts +0 -0
- package/dist/types/ITimeSeries.js +0 -0
- package/exec/console.js +110 -110
- package/exec/db.rws.webpack.config.js +168 -168
- package/exec/src/cli.ts +73 -75
- package/exec/tsconfig.json +32 -32
- package/exec/webpackFilters.js +17 -17
- package/package.json +36 -36
- package/src/decorators/IdType.ts +17 -0
- package/src/decorators/InverseRelation.ts +41 -37
- package/src/decorators/InverseTimeSeries.ts +21 -21
- package/src/decorators/RWSCollection.ts +45 -27
- package/src/decorators/Relation.ts +61 -48
- package/src/decorators/TrackType.ts +65 -69
- package/src/decorators/index.ts +16 -8
- package/src/empty.js +0 -0
- package/src/helper/DbHelper.ts +133 -223
- package/src/helper/FieldsHelper.ts +34 -34
- package/src/helper/db/index.ts +10 -0
- package/src/helper/db/relation-manager.ts +119 -0
- package/src/helper/db/schema-generator.ts +302 -0
- package/src/helper/db/type-converter.ts +119 -0
- package/src/helper/db/utils.ts +120 -0
- package/src/index.ts +47 -38
- package/src/models/_model.ts +29 -29
- package/src/models/core/RWSModel.ts +523 -520
- package/src/models/core/TimeSeriesModel.ts +19 -19
- package/src/models/index.ts +20 -20
- package/src/models/interfaces/IDbOpts.ts +17 -0
- package/src/models/interfaces/IIdTypeOpts.ts +4 -0
- package/src/models/interfaces/IModel.ts +12 -12
- package/src/models/interfaces/IRWSModelServices.ts +7 -7
- package/src/models/interfaces/ITrackerOpts.ts +13 -0
- package/src/models/interfaces/OpModelType.ts +52 -49
- package/src/models/types/RelationTypes.ts +25 -25
- package/src/models/utils/ModelUtils.ts +65 -65
- package/src/models/utils/PaginationUtils.ts +42 -42
- package/src/models/utils/RelationUtils.ts +76 -76
- package/src/models/utils/TimeSeriesUtils.ts +38 -38
- package/src/services/DBService.ts +277 -277
- package/src/types/DbConfigHandler.ts +17 -17
- package/src/types/FindParams.ts +13 -13
- package/src/types/IRWSModel.ts +2 -2
- package/src/types/ITimeSeries.ts +5 -5
- package/tsconfig.json +22 -22
|
@@ -94,7 +94,7 @@ class RWSModel {
|
|
|
94
94
|
continue;
|
|
95
95
|
}
|
|
96
96
|
const relMeta = relManyData[key];
|
|
97
|
-
const relationEnabled = RelationUtils_1.RelationUtils.
|
|
97
|
+
const relationEnabled = !RelationUtils_1.RelationUtils.checkRelDisabled(this, relMeta.key);
|
|
98
98
|
if (relationEnabled) {
|
|
99
99
|
this[relMeta.key] = await relMeta.inversionModel.findBy({
|
|
100
100
|
conditions: {
|
|
@@ -110,7 +110,7 @@ class RWSModel {
|
|
|
110
110
|
continue;
|
|
111
111
|
}
|
|
112
112
|
const relMeta = relOneData[key];
|
|
113
|
-
const relationEnabled = RelationUtils_1.RelationUtils.
|
|
113
|
+
const relationEnabled = !RelationUtils_1.RelationUtils.checkRelDisabled(this, relMeta.key);
|
|
114
114
|
if (!data[relMeta.hydrationField] && relMeta.required) {
|
|
115
115
|
throw new Error(`Relation field "${relMeta.hydrationField}" is required in model ${this.constructor.name}.`);
|
|
116
116
|
}
|
|
@@ -373,8 +373,8 @@ class RWSModel {
|
|
|
373
373
|
loadModels() {
|
|
374
374
|
return RWSModel.loadModels();
|
|
375
375
|
}
|
|
376
|
-
|
|
377
|
-
return RelationUtils_1.RelationUtils.
|
|
376
|
+
checkRelDisabled(key) {
|
|
377
|
+
return RelationUtils_1.RelationUtils.checkRelDisabled(this, key);
|
|
378
378
|
}
|
|
379
379
|
static setServices(services) {
|
|
380
380
|
this.allModels = services.configService.get('db_models');
|
|
@@ -391,6 +391,8 @@ exports.RWSModel = RWSModel;
|
|
|
391
391
|
RWSModel.services = {};
|
|
392
392
|
RWSModel._collection = null;
|
|
393
393
|
RWSModel._RELATIONS = {};
|
|
394
|
+
RWSModel._NO_ID = false;
|
|
395
|
+
RWSModel._SUPER_TAGS = [];
|
|
394
396
|
RWSModel._BANNED_KEYS = ['_collection'];
|
|
395
397
|
RWSModel.allModels = [];
|
|
396
398
|
RWSModel._CUT_KEYS = [];
|
|
File without changes
|
|
File without changes
|
package/dist/models/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { IRWSModelServices } from './interfaces/IRWSModelServices';
|
|
|
3
3
|
import { OpModelType } from './interfaces/OpModelType';
|
|
4
4
|
import { RelationBindType, RelOneMetaType, RelManyMetaType } from './types/RelationTypes';
|
|
5
5
|
import { RWSModel } from './core/RWSModel';
|
|
6
|
-
import { TrackType,
|
|
7
|
-
export { IModel, IRWSModelServices, OpModelType, RelationBindType, RelOneMetaType, RelManyMetaType, RWSModel, TrackType,
|
|
6
|
+
import { TrackType, ITrackerMetaOpts } from '../decorators';
|
|
7
|
+
export { IModel, IRWSModelServices, OpModelType, RelationBindType, RelOneMetaType, RelManyMetaType, RWSModel, TrackType, ITrackerMetaOpts };
|
package/dist/models/index.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface IDbOpts {
|
|
2
|
+
dbOptions?: {
|
|
3
|
+
mysql?: {
|
|
4
|
+
useType?: string;
|
|
5
|
+
useText?: boolean;
|
|
6
|
+
maxLength?: number;
|
|
7
|
+
useUuid?: boolean;
|
|
8
|
+
};
|
|
9
|
+
postgres?: {
|
|
10
|
+
useText?: boolean;
|
|
11
|
+
useUuid?: boolean;
|
|
12
|
+
};
|
|
13
|
+
mongodb?: {
|
|
14
|
+
customType?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IDbOpts } from "./IDbOpts";
|
|
2
|
+
import { OpModelType } from "./OpModelType";
|
|
3
|
+
export interface ITrackerOpts extends IDbOpts {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
unique?: boolean | string;
|
|
6
|
+
isArray?: boolean;
|
|
7
|
+
relationField?: string;
|
|
8
|
+
relatedToField?: string;
|
|
9
|
+
relatedTo?: OpModelType<any>;
|
|
10
|
+
inversionModel?: OpModelType<any>;
|
|
11
|
+
relationName?: string;
|
|
12
|
+
}
|
|
@@ -4,11 +4,14 @@ import { IRWSModelServices } from './IRWSModelServices';
|
|
|
4
4
|
import { RelOneMetaType, RelManyMetaType } from '../types/RelationTypes';
|
|
5
5
|
import { DBService } from '../../services/DBService';
|
|
6
6
|
import type { RWSModel } from '../core/RWSModel';
|
|
7
|
+
import { ISuperTagData } from '../../decorators/RWSCollection';
|
|
7
8
|
export interface OpModelType<T> {
|
|
8
9
|
new (data?: any | null): T;
|
|
9
10
|
services: IRWSModelServices;
|
|
10
11
|
name: string;
|
|
11
12
|
_collection: string;
|
|
13
|
+
_NO_ID: boolean;
|
|
14
|
+
_SUPER_TAGS: ISuperTagData[];
|
|
12
15
|
_RELATIONS: {
|
|
13
16
|
[key: string]: boolean;
|
|
14
17
|
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -57,9 +57,9 @@ class RelationUtils {
|
|
|
57
57
|
// Check if the property exists and is an object with an id property
|
|
58
58
|
return !!model[key] && typeof model[key] === 'object' && model[key] !== null && 'id' in model[key];
|
|
59
59
|
}
|
|
60
|
-
static
|
|
60
|
+
static checkRelDisabled(model, key) {
|
|
61
61
|
return Object.keys(model.constructor._RELATIONS).includes(key) &&
|
|
62
|
-
model.constructor._RELATIONS[key] ===
|
|
62
|
+
model.constructor._RELATIONS[key] === false;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
exports.RelationUtils = RelationUtils;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,7 +2,7 @@ import { OpModelType } from "../models/interfaces/OpModelType";
|
|
|
2
2
|
export interface IDbConfigParams {
|
|
3
3
|
db_url?: string;
|
|
4
4
|
db_name?: string;
|
|
5
|
-
db_type?: 'mongodb' | 'mysql' | 'sqlite';
|
|
5
|
+
db_type?: 'mongodb' | 'mysql' | 'sqlite' | 'postgresql' | 'postgres';
|
|
6
6
|
db_models?: OpModelType<any>[];
|
|
7
7
|
}
|
|
8
8
|
export interface IdGeneratorOptions {
|
|
File without changes
|
|
File without changes
|
package/dist/types/FindParams.js
CHANGED
|
File without changes
|
package/dist/types/IRWSModel.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/exec/console.js
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { rwsShell, rwsPath } = require('@rws-framework/console');
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const crypto = require('crypto');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
|
|
9
|
-
const params = process.argv.splice(2);
|
|
10
|
-
let paramsString = params.length ? (' ' + params.join(' ')) : '';
|
|
11
|
-
|
|
12
|
-
const appRoot = process.cwd();
|
|
13
|
-
const rwsCliConfigDir = path.resolve(appRoot, 'node_modules', '.rws', 'cli');
|
|
14
|
-
const getCachedPath = (key) => path.resolve(rwsCliConfigDir, key);
|
|
15
|
-
|
|
16
|
-
const currentCwd = path.resolve(__dirname);
|
|
17
|
-
|
|
18
|
-
console.log({params})
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const commandString = `npx webpack --config db.rws.webpack.config.js --output-path ./build ${process.cwd()} ${params[2]}`;
|
|
22
|
-
function needsCacheWarming(){
|
|
23
|
-
|
|
24
|
-
if(!fs.existsSync(getCachedPath('paths')) || !fs.existsSync(getCachedPath('checksum'))){
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const fileList = fs.readFileSync(getCachedPath('paths'), 'utf-8').split('\n');
|
|
29
|
-
|
|
30
|
-
if(fileList.length){
|
|
31
|
-
const fileContents = [];
|
|
32
|
-
for(const filePath of fileList){
|
|
33
|
-
if(fs.existsSync(filePath)){
|
|
34
|
-
fileContents.push(fs.readFileSync(filePath, 'utf-8'));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const finalMD5 = crypto.createHash('md5').update(fileContents.join('\n')).digest('hex');
|
|
38
|
-
const cachedMD5 = fs.readFileSync(getCachedPath('checksum'), 'utf-8');
|
|
39
|
-
|
|
40
|
-
if(finalMD5 === cachedMD5){
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function main()
|
|
49
|
-
{
|
|
50
|
-
const hasRebuild = paramsString.split(' ').pop().indexOf('--rebuild') > -1;
|
|
51
|
-
const doWarmCache = needsCacheWarming() || hasRebuild;
|
|
52
|
-
|
|
53
|
-
if(!((params[0] || false) && (params[1] || false) && (params[2] || false))){
|
|
54
|
-
throw new Error(`CLI command MUST have 3 parameters: {DB_URL, DB_NAME, MODELS_DIR}`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if(doWarmCache){
|
|
58
|
-
console.log(chalk.yellow('[RWS DB CLI] Building CLI client...'));
|
|
59
|
-
|
|
60
|
-
const cacheTypes = ['paths', 'checksum'];
|
|
61
|
-
|
|
62
|
-
for(const type of cacheTypes){
|
|
63
|
-
if(fs.existsSync(getCachedPath(type))){
|
|
64
|
-
fs.unlinkSync(getCachedPath(type));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
await tsc();
|
|
69
|
-
|
|
70
|
-
await rwsShell.runCommand(commandString, currentCwd);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}else{
|
|
74
|
-
console.log(chalk.blue('[RWS CLI CACHE] Starting command from built CLI client.'));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let startSlice = hasRebuild ? -1 : paramsString.split(' ').length;
|
|
78
|
-
let endSlice = hasRebuild ? -1 : null ;
|
|
79
|
-
|
|
80
|
-
paramsString = [
|
|
81
|
-
...paramsString.split(' ').slice(0, startSlice),
|
|
82
|
-
currentCwd,
|
|
83
|
-
endSlice ?
|
|
84
|
-
paramsString.split(' ').at(endSlice)
|
|
85
|
-
: null
|
|
86
|
-
].filter((item) => item !== null).join(' ');
|
|
87
|
-
|
|
88
|
-
await rwsShell.runCommand(`node ${path.join(currentCwd, 'build', 'main.cli.rws.js')}${paramsString}`, process.cwd());
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async function tsc (){
|
|
92
|
-
const tempConfigContent = {
|
|
93
|
-
"extends": "./tsconfig.json",
|
|
94
|
-
"include": [
|
|
95
|
-
path.join(process.cwd(), params[2], 'index.ts')
|
|
96
|
-
],
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const tempConfigPath = path.join(currentCwd, '.tmp.gitignore.json');
|
|
100
|
-
fs.writeFileSync(tempConfigPath, JSON.stringify(tempConfigContent, null, 2));
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
await rwsShell.runCommand(`tsc -p ${tempConfigPath}`, currentCwd);
|
|
104
|
-
fs.unlinkSync(tempConfigPath);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
main().then((data) => {
|
|
108
|
-
console.log(chalk.green('[RWS DB CLI] Command complete.'));
|
|
109
|
-
}).catch((e) => {
|
|
110
|
-
console.error(e.message);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { rwsShell, rwsPath } = require('@rws-framework/console');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const crypto = require('crypto');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
|
|
9
|
+
const params = process.argv.splice(2);
|
|
10
|
+
let paramsString = params.length ? (' ' + params.join(' ')) : '';
|
|
11
|
+
|
|
12
|
+
const appRoot = process.cwd();
|
|
13
|
+
const rwsCliConfigDir = path.resolve(appRoot, 'node_modules', '.rws', 'cli');
|
|
14
|
+
const getCachedPath = (key) => path.resolve(rwsCliConfigDir, key);
|
|
15
|
+
|
|
16
|
+
const currentCwd = path.resolve(__dirname);
|
|
17
|
+
|
|
18
|
+
console.log({params})
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const commandString = `npx webpack --config db.rws.webpack.config.js --output-path ./build ${process.cwd()} ${params[2]}`;
|
|
22
|
+
function needsCacheWarming(){
|
|
23
|
+
|
|
24
|
+
if(!fs.existsSync(getCachedPath('paths')) || !fs.existsSync(getCachedPath('checksum'))){
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const fileList = fs.readFileSync(getCachedPath('paths'), 'utf-8').split('\n');
|
|
29
|
+
|
|
30
|
+
if(fileList.length){
|
|
31
|
+
const fileContents = [];
|
|
32
|
+
for(const filePath of fileList){
|
|
33
|
+
if(fs.existsSync(filePath)){
|
|
34
|
+
fileContents.push(fs.readFileSync(filePath, 'utf-8'));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const finalMD5 = crypto.createHash('md5').update(fileContents.join('\n')).digest('hex');
|
|
38
|
+
const cachedMD5 = fs.readFileSync(getCachedPath('checksum'), 'utf-8');
|
|
39
|
+
|
|
40
|
+
if(finalMD5 === cachedMD5){
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function main()
|
|
49
|
+
{
|
|
50
|
+
const hasRebuild = paramsString.split(' ').pop().indexOf('--rebuild') > -1;
|
|
51
|
+
const doWarmCache = needsCacheWarming() || hasRebuild;
|
|
52
|
+
|
|
53
|
+
if(!((params[0] || false) && (params[1] || false) && (params[2] || false))){
|
|
54
|
+
throw new Error(`CLI command MUST have 3 parameters: {DB_URL, DB_NAME, MODELS_DIR}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if(doWarmCache){
|
|
58
|
+
console.log(chalk.yellow('[RWS DB CLI] Building CLI client...'));
|
|
59
|
+
|
|
60
|
+
const cacheTypes = ['paths', 'checksum'];
|
|
61
|
+
|
|
62
|
+
for(const type of cacheTypes){
|
|
63
|
+
if(fs.existsSync(getCachedPath(type))){
|
|
64
|
+
fs.unlinkSync(getCachedPath(type));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
await tsc();
|
|
69
|
+
|
|
70
|
+
await rwsShell.runCommand(commandString, currentCwd);
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
}else{
|
|
74
|
+
console.log(chalk.blue('[RWS CLI CACHE] Starting command from built CLI client.'));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
let startSlice = hasRebuild ? -1 : paramsString.split(' ').length;
|
|
78
|
+
let endSlice = hasRebuild ? -1 : null ;
|
|
79
|
+
|
|
80
|
+
paramsString = [
|
|
81
|
+
...paramsString.split(' ').slice(0, startSlice),
|
|
82
|
+
currentCwd,
|
|
83
|
+
endSlice ?
|
|
84
|
+
paramsString.split(' ').at(endSlice)
|
|
85
|
+
: null
|
|
86
|
+
].filter((item) => item !== null).join(' ');
|
|
87
|
+
|
|
88
|
+
await rwsShell.runCommand(`node ${path.join(currentCwd, 'build', 'main.cli.rws.js')}${paramsString}`, process.cwd());
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function tsc (){
|
|
92
|
+
const tempConfigContent = {
|
|
93
|
+
"extends": "./tsconfig.json",
|
|
94
|
+
"include": [
|
|
95
|
+
path.join(process.cwd(), params[2], 'index.ts')
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const tempConfigPath = path.join(currentCwd, '.tmp.gitignore.json');
|
|
100
|
+
fs.writeFileSync(tempConfigPath, JSON.stringify(tempConfigContent, null, 2));
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
await rwsShell.runCommand(`tsc -p ${tempConfigPath}`, currentCwd);
|
|
104
|
+
fs.unlinkSync(tempConfigPath);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
main().then((data) => {
|
|
108
|
+
console.log(chalk.green('[RWS DB CLI] Command complete.'));
|
|
109
|
+
}).catch((e) => {
|
|
110
|
+
console.error(e.message);
|
|
111
111
|
});
|