🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

lambdaorm-cli

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambdaorm-cli - npm Package Compare versions

Comparing version

to
0.8.7

@@ -5,3 +5,3 @@ import { OrmCliService } from '../services/ormCli';

constructor(service: OrmCliService);
execute(workspace: string, language: string, options: string[]): Promise<void>;
execute(workspace: string, language: string, options: string[], srcPath?: string, dataPath?: string): Promise<void>;
}

@@ -11,5 +11,9 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Build = void 0;
const lambdaorm_1 = require("lambdaorm");
const path_1 = __importDefault(require("path"));
class Build {

@@ -20,3 +24,3 @@ // eslint-disable-next-line no-useless-constructor

}
execute(workspace, language, options) {
execute(workspace, language, options, srcPath, dataPath) {
return __awaiter(this, void 0, void 0, function* () {

@@ -29,9 +33,10 @@ const orm = new lambdaorm_1.Orm(workspace);

}
const _srcPath = srcPath || schema.infrastructure.paths.src;
const _dataPath = dataPath || schema.infrastructure.paths.data;
const modelPath = path_1.default.join(workspace, _srcPath, _dataPath);
if (options.includes('model')) {
// write model
yield languageService.buildModel(workspace, schema);
yield languageService.buildModel(modelPath, schema.domain);
}
if (options.includes('repositories')) {
// write repositories
yield languageService.buildRepositories(workspace, schema);
yield languageService.buildRepositories(modelPath, schema.domain);
}

@@ -38,0 +43,0 @@ });

@@ -7,3 +7,3 @@ import { Helper } from '../helper';

constructor(service: OrmCliService, helper: Helper);
execute(workspace: string, language: string, source?: string, dialect?: string, connection?: string): Promise<void>;
execute(workspace: string, language: string, source?: string, dialect?: string, connection?: string, srcPath?: string, dataPath?: string): Promise<void>;
}

@@ -25,3 +25,3 @@ "use strict";

}
execute(workspace, language, source, dialect, connection) {
execute(workspace, language, source, dialect, connection, srcPath, dataPath) {
return __awaiter(this, void 0, void 0, function* () {

@@ -43,7 +43,11 @@ const orm = new lambdaorm_1.Orm(workspace);

const configPath = path_1.default.join(workspace, 'lambdaORM.yaml');
const _srcPath = srcPath || targetSchema.infrastructure.paths.src;
const _dataPath = dataPath || targetSchema.infrastructure.paths.data;
yield schemaService.writeSchema(configPath, targetSchema);
// create structure
yield languageService.createStructure(workspace, targetSchema);
yield languageService.createStructure(workspace, _srcPath, _dataPath);
// add libraries for dialect
yield languageService.addDialects(workspace, targetSchema);
if (targetSchema.infrastructure && targetSchema.infrastructure.sources && targetSchema.infrastructure.sources.length > 0) {
yield languageService.addDialects(workspace, targetSchema.infrastructure);
}
});

@@ -50,0 +54,0 @@ }

@@ -5,3 +5,3 @@ import { OrmCliService } from '../services/ormCli';

constructor(service: OrmCliService);
execute(workspace: string, language: string, onlyModel: boolean): Promise<void>;
execute(workspace: string, language: string, onlyModel: boolean, srcPath?: string, dataPath?: string): Promise<void>;
}

@@ -11,5 +11,9 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Update = void 0;
const lambdaorm_1 = require("lambdaorm");
const path_1 = __importDefault(require("path"));
class Update {

@@ -20,3 +24,3 @@ // eslint-disable-next-line no-useless-constructor

}
execute(workspace, language, onlyModel) {
execute(workspace, language, onlyModel, srcPath, dataPath) {
return __awaiter(this, void 0, void 0, function* () {

@@ -30,14 +34,18 @@ const orm = new lambdaorm_1.Orm(workspace);

schema = yield orm.schema.initialize(schema);
const _srcPath = srcPath || schema.infrastructure.paths.src;
const _dataPath = dataPath || schema.infrastructure.paths.data;
if (!onlyModel) {
// create structure
yield languageService.createStructure(workspace, schema);
yield languageService.createStructure(workspace, _srcPath, _dataPath);
// add libraries for dialect
yield languageService.addDialects(workspace, schema);
if (schema.infrastructure && schema.infrastructure.sources && schema.infrastructure.sources.length > 0) {
yield languageService.addDialects(workspace, schema.infrastructure);
}
}
// TODO cambiar por complete dado que el modelo se debe escribir sin extenderlo
orm.schema.complete(schema);
// write model
yield languageService.buildModel(workspace, schema);
// write repositories
yield languageService.buildRepositories(workspace, schema);
// write model and repositories
const modelPath = path_1.default.join(workspace, _srcPath, _dataPath);
yield languageService.buildModel(modelPath, schema.domain);
yield languageService.buildRepositories(modelPath, schema.domain);
});

@@ -44,0 +52,0 @@ }

@@ -1,9 +0,9 @@

import { Schema } from 'lambdaorm';
import { DomainSchema, InfrastructureSchema } from 'lambdaorm';
export interface LanguagePort {
get name(): string;
createStructure(workspace: string, schema: Schema): Promise<void>;
addDialects(workspace: string, schema: Schema): Promise<void>;
createStructure(workspace: string, srcPath: string, dataPath?: string): Promise<void>;
addDialects(path: string, infrastructure: InfrastructureSchema): Promise<void>;
localVersion(workspace: string): Promise<string>;
buildModel(workspace: string, schema: Schema): Promise<void>;
buildRepositories(workspace: string, schema: Schema): Promise<void>;
buildModel(modelPath: string, domain: DomainSchema): Promise<void>;
buildRepositories(modelPath: string, domain: DomainSchema): Promise<void>;
}

@@ -14,2 +14,3 @@ "use strict";

service.addLanguage(new languages_1.NodeLanguageAdapter(this.helper));
service.addLanguage(new languages_1.ClientNodeLanguageAdapter(this.helper));
return service;

@@ -16,0 +17,0 @@ }

@@ -15,4 +15,8 @@ import { CommandModule, Argv, Arguments } from 'yargs';

a: unknown;
} & {
"src-path": unknown;
} & {
"data-path": unknown;
}>;
handler(args: Arguments): Promise<void>;
}

@@ -41,2 +41,10 @@ "use strict";

describe: 'build all'
})
.option('src-path', {
alias: 'srcPath',
describe: 'update only model'
})
.option('data-path', {
alias: 'dataPath',
describe: 'update only model'
});

@@ -51,2 +59,4 @@ }

const all = args.all !== undefined;
const srcPath = args.srcPath;
const dataPath = args.dataPath;
const options = [];

@@ -60,3 +70,3 @@ if (model || all) {

try {
yield usesCases_1.build.execute(workspace, language, options);
yield usesCases_1.build.execute(workspace, language, options, srcPath, dataPath);
}

@@ -63,0 +73,0 @@ catch (error) {

@@ -11,4 +11,8 @@ import { CommandModule, Argv, Arguments } from 'yargs';

"only-model": unknown;
} & {
"src-path": unknown;
} & {
"data-path": unknown;
}>;
handler(args: Arguments): Promise<void>;
}

@@ -37,2 +37,10 @@ "use strict";

describe: 'update only model'
})
.option('src-path', {
alias: 'srcPath',
describe: 'update only model'
})
.option('data-path', {
alias: 'dataPath',
describe: 'update only model'
});

@@ -45,4 +53,6 @@ }

const onlyModel = args.onlyModel !== undefined;
const srcPath = args.srcPath;
const dataPath = args.dataPath;
try {
yield usesCases_1.update.execute(workspace, language, onlyModel);
yield usesCases_1.update.execute(workspace, language, onlyModel, srcPath, dataPath);
}

@@ -49,0 +59,0 @@ catch (error) {

export * from './node';
export * from './clientNode';

@@ -18,2 +18,3 @@ "use strict";

__exportStar(require("./node"), exports);
__exportStar(require("./clientNode"), exports);
//# sourceMappingURL=index.js.map

@@ -1,19 +0,54 @@

import { Schema } from 'lambdaorm';
import { Entity, DomainSchema, InfrastructureSchema } from 'lambdaorm';
import { Helper } from '../../application';
import { LanguagePort } from '../../domain';
export declare class NodeLanguageAdapter implements LanguagePort {
private readonly helper;
protected library: string;
protected helper: Helper;
constructor(helper: Helper);
get name(): string;
createStructure(workspace: string, schema: Schema): Promise<void>;
addDialects(workspace: string, schema: Schema): Promise<void>;
/**
* if the package.json does not exist create it
*/
protected createPackage(workspace: string): Promise<void>;
/**
* if the tsconfig.json does not exist create it
*/
protected createTsconfig(workspace: string): Promise<void>;
/**
* if the typescript is not installed locally it will be installed
*/
protected installTypescript(workspace: string): Promise<void>;
/**
* if the lambdaorm is not installed locally it will be installed
*/
protected installLibrary(workspace: string): Promise<void>;
createStructure(workspace: string, srcPath: string, dataPath?: string): Promise<void>;
addDialects(path: string, infrastructure: InfrastructureSchema): Promise<void>;
localVersion(workspace: string): Promise<string>;
buildModel(workspace: string, schema: Schema): Promise<void>;
buildRepositories(workspace: string, schema: Schema): Promise<void>;
private getLocalPackage;
private getLibs;
private getTypescriptContent;
private getRepositoryContent;
private getModelContent;
private getType;
buildModel(modelPath: string, domain: DomainSchema): Promise<void>;
buildRepositories(modelPath: string, domain: DomainSchema): Promise<void>;
protected getLocalPackage(name: string, workspace: string): Promise<string>;
protected getLibs(dialect: string): string[];
protected getTypescriptContent(): {
compilerOptions: {
experimentalDecorators: boolean;
emitDecoratorMetadata: boolean;
resolveJsonModule: boolean;
esModuleInterop: boolean;
strict: boolean;
declaration: boolean;
moduleResolution: string;
sourceMap: boolean;
target: string;
module: string;
outDir: string;
baseUrl: string;
typeRoots: string[];
};
include: string[];
exclude: string[];
};
protected getRepositoryContent(entity: Entity): string;
protected getModelContent(source: DomainSchema): string;
protected getType(type: string): string;
}

@@ -19,5 +19,5 @@ "use strict";

class NodeLanguageAdapter {
// eslint-disable-next-line no-useless-constructor
constructor(helper) {
this.helper = helper;
this.library = 'lambdaorm';
}

@@ -28,8 +28,7 @@ get name() {

// eslint-disable-next-line no-useless-constructor
createStructure(workspace, schema) {
/**
* if the package.json does not exist create it
*/
createPackage(workspace) {
return __awaiter(this, void 0, void 0, function* () {
// create initial structure
yield this.helper.fs.create(path_1.default.join(workspace, schema.infrastructure.paths.src));
yield this.helper.fs.create(path_1.default.join(workspace, schema.infrastructure.paths.data));
// if the package.json does not exist create it
const packagePath = path_1.default.join(workspace, 'package.json');

@@ -39,3 +38,9 @@ if (!(yield this.helper.fs.exists(packagePath))) {

}
// if there is no tsconfig.json create it
});
}
/**
* if the tsconfig.json does not exist create it
*/
createTsconfig(workspace) {
return __awaiter(this, void 0, void 0, function* () {
const tsconfigPath = path_1.default.join(workspace, 'tsconfig.json');

@@ -46,3 +51,9 @@ if (!(yield this.helper.fs.exists(tsconfigPath))) {

}
// install typescript if not installed.
});
}
/**
* if the typescript is not installed locally it will be installed
*/
installTypescript(workspace) {
return __awaiter(this, void 0, void 0, function* () {
const typescriptLib = yield this.getLocalPackage('typescript', workspace);

@@ -52,13 +63,32 @@ if (typescriptLib === '') {

}
// install lambdaorm if it is not installed.
const lambdaormLib = yield this.getLocalPackage('lambdaorm', workspace);
});
}
/**
* if the lambdaorm is not installed locally it will be installed
*/
installLibrary(workspace) {
return __awaiter(this, void 0, void 0, function* () {
const lambdaormLib = yield this.getLocalPackage(this.library, workspace);
if (lambdaormLib === '') {
yield this.helper.cli.exec('npm install lambdaorm', workspace);
yield this.helper.cli.exec(`npm install ${this.library}`, workspace);
}
});
}
addDialects(workspace, schema) {
createStructure(workspace, srcPath, dataPath) {
return __awaiter(this, void 0, void 0, function* () {
for (const p in schema.infrastructure.sources) {
const source = schema.infrastructure.sources[p];
// create initial structure
yield this.helper.fs.create(path_1.default.join(workspace, srcPath));
if (dataPath) {
yield this.helper.fs.create(path_1.default.join(workspace, dataPath));
}
yield this.createPackage(workspace);
yield this.createTsconfig(workspace);
yield this.installTypescript(workspace);
yield this.installLibrary(workspace);
});
}
addDialects(path, infrastructure) {
return __awaiter(this, void 0, void 0, function* () {
for (const p in infrastructure.sources) {
const source = infrastructure.sources[p];
// if the library is not installed locally corresponding to the dialect it will be installed

@@ -68,5 +98,5 @@ const libs = this.getLibs(source.dialect);

const lib = libs[p];
const localLib = yield this.getLocalPackage(lib, workspace);
const localLib = yield this.getLocalPackage(lib, path);
if (localLib === '') {
yield this.helper.cli.exec(`npm install ${lib}`, workspace);
yield this.helper.cli.exec(`npm install ${lib}`, path);
}

@@ -82,21 +112,19 @@ }

}
buildModel(workspace, schema) {
buildModel(modelPath, domain) {
return __awaiter(this, void 0, void 0, function* () {
const content = this.getModelContent(schema);
const modelsPath = path_1.default.join(workspace, schema.infrastructure.paths.src, schema.infrastructure.paths.domain);
this.helper.fs.create(modelsPath);
const schemaPath = path_1.default.join(modelsPath, 'model.ts');
const content = this.getModelContent(domain);
this.helper.fs.create(modelPath);
const schemaPath = path_1.default.join(modelPath, 'model.ts');
yield this.helper.fs.write(schemaPath, content);
});
}
buildRepositories(workspace, schema) {
buildRepositories(modelPath, domain) {
return __awaiter(this, void 0, void 0, function* () {
const modelsPath = path_1.default.join(workspace, schema.infrastructure.paths.src, schema.infrastructure.paths.domain);
this.helper.fs.create(modelsPath);
for (const q in schema.domain.entities) {
const entity = schema.domain.entities[q];
this.helper.fs.create(modelPath);
for (const q in domain.entities) {
const entity = domain.entities[q];
if (entity.abstract)
continue;
const singular = entity.singular ? entity.singular : this.helper.str.singular(entity.name);
const repositoryPath = path_1.default.join(modelsPath, `repository${singular}.ts`);
const repositoryPath = path_1.default.join(modelPath, `repository${singular}.ts`);
if (!(yield this.helper.fs.exists(repositoryPath))) {

@@ -170,7 +198,7 @@ const repositoryContent = this.getRepositoryContent(entity);

const singular = entity.singular ? entity.singular : this.helper.str.singular(entity.name);
lines.push('import { Repository, IOrm } from \'lambdaorm\'');
lines.push(`import { Repository, IOrm } from '${this.library}'`);
lines.push(`import { ${singular}, Qry${singular} } from './model'`);
lines.push(`export class ${singular}Repository extends Repository<${singular}, Qry${singular}> {`);
lines.push('\tconstructor (stage?: string, Orm?:IOrm) {');
lines.push(`\t\tsuper('${entity.name}', stage, Orm)`);
lines.push('\tconstructor (stage?: string, orm?:IOrm) {');
lines.push(`\t\tsuper('${entity.name}', stage, orm)`);
lines.push('\t}');

@@ -185,6 +213,7 @@ lines.push('\t// Add your code here');

lines.push('// THIS FILE IS NOT EDITABLE, IS MANAGED BY LAMBDA ORM');
lines.push('import { Queryable, OneToMany, ManyToOne, OneToOne } from \'lambdaorm\'');
if (source.domain.enums) {
for (const p in source.domain.enums) {
const _enum = source.domain.enums[p];
lines.push('// eslint-disable-next-line @typescript-eslint/no-unused-vars');
lines.push(`import { Queryable, OneToMany, ManyToOne, OneToOne } from '${this.library}'`);
if (source.enums) {
for (const p in source.enums) {
const _enum = source.enums[p];
lines.push(`export enum ${_enum.name}{`);

@@ -204,5 +233,5 @@ for (let j = 0; j < _enum.values.length; j++) {

}
if (source.domain.entities) {
for (const p in source.domain.entities) {
const entity = source.domain.entities[p];
if (source.entities) {
for (const p in source.entities) {
const entity = source.entities[p];
const singular = entity.singular ? entity.singular : this.helper.str.singular(entity.name);

@@ -239,3 +268,3 @@ const _abstract = entity.abstract ? ' abstract ' : ' ';

const relation = entity.relations[q];
const relationEntity = source.domain.entities.find(p => p.name === relation.entity);
const relationEntity = source.entities.find(p => p.name === relation.entity);
if (relationEntity === undefined) {

@@ -267,3 +296,3 @@ throw new Error(`Not exists ${relation.entity} relation in ${entity.name} entity`);

const relation = entity.relations[q];
const relationEntity = source.domain.entities.find(p => p.name === relation.entity);
const relationEntity = source.entities.find(p => p.name === relation.entity);
const relationEntitySingularName = relationEntity.singular ? relationEntity.singular : this.helper.str.singular(relationEntity.name);

@@ -284,4 +313,4 @@ switch (relation.type) {

}
for (const p in source.domain.entities) {
const entity = source.domain.entities[p];
for (const p in source.entities) {
const entity = source.entities[p];
if (!entity.abstract) {

@@ -288,0 +317,0 @@ const singular = entity.singular ? entity.singular : this.helper.str.singular(entity.name);

{
"name": "lambdaorm-cli",
"version": "0.8.3",
"version": "0.8.7",
"description": "The lambdaorm command line interface",

@@ -29,3 +29,3 @@ "author": "Flavio Lionel Rita <flaviolrita@hotmail.com>",

"js-yaml": "^4.1.0",
"lambdaorm": "0.8.64",
"lambdaorm": "0.8.76",
"mongodb": "^5.7.0",

@@ -32,0 +32,0 @@ "mysql2": "^3.4.0",

@@ -38,2 +38,4 @@ # λORM CLI

- [lambdaorm](https://github.com/FlavioLionelRita/lambdaorm)
- [lambdaorm service](https://github.com/FlavioLionelRita/lambdaorm-svc)
- [lambdaorm client node](https://github.com/FlavioLionelRita/lambdaorm-client-node)
- [Labs](https://github.com/FlavioLionelRita/lambdaorm-cli/wiki/Labs)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet