Skip to content

Commit

Permalink
fix(sandbox): fix lint issues in sandbox
Browse files Browse the repository at this point in the history
prettier fix

MIGRATION CHANGE:
migration-20221122072057- fix lint issues in sandbox
migration-20221123082705- prettier fix
migration-20220620093215- prettier:fix

BREAKING CHANGE:
lerna bootstrap command will not be supported

GH-1673
  • Loading branch information
shubhamp-sf authored and Surbhi-sharma1 committed Sep 12, 2023
1 parent 1b54515 commit 2ac3311
Show file tree
Hide file tree
Showing 55 changed files with 4,664 additions and 3,164 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
run: npm ci

- name: Bootstrap Monorepo
run: npx lerna bootstrap
run: npm ci

- name: Run Test Cases
run: npx lerna run test
run: npm run test --workspaces --if-present

- name: Run Lint Checks
run: npx lerna run lint
run: npm run lint --workspaces --if-present
7,509 changes: 4,505 additions & 3,004 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions packages/cli/src/generators/microservice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import fs from 'fs';
import {join} from 'path';
import AppGenerator from '../../app-generator';
import {
BASESERVICECOMPONENTLIST,
BASESERVICEDSLIST,
DATASOURCES,
DATASOURCE_CONNECTORS,
MIGRATIONS,
MIGRATION_CONNECTORS,
SERVICES,
BASESERVICEDSLIST,
BASESERVICECOMPONENTLIST,
} from '../../enum';
import {AnyObject, MicroserviceOptions} from '../../types';
import {
JSON_SPACING,
appendDependencies,
getDependencyVersion,
JSON_SPACING,
} from '../../utils';
const chalk = require('chalk'); //NOSONAR

Expand Down Expand Up @@ -179,6 +179,7 @@ export default class MicroserviceGenerator extends AppGenerator<MicroserviceOpti

writing() {
if (!this.shouldExit()) {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (this.options.baseService || this.options.datasourceName) {
this._createDataSource();
} else {
Expand Down
2 changes: 0 additions & 2 deletions packages/core/.npmrc

This file was deleted.

2 changes: 0 additions & 2 deletions packages/feature-toggle/.npmrc

This file was deleted.

2 changes: 0 additions & 2 deletions sandbox/audit-ms-example/.npmrc

This file was deleted.

4 changes: 2 additions & 2 deletions sandbox/audit-ms-example/src/enums/permissions.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
// https://opensource.org/licenses/MIT
export declare const enum PermissionKey {
CreateTodo = 'TodoCreator',
UpdateTodo = 'TodoCreator',
DeleteTodo = 'TodoCreator',
UpdateTodo = 'UpdateTodoCreator',
DeleteTodo = 'DeleteTodoCreator',
}
5 changes: 3 additions & 2 deletions sandbox/audit-ms-example/src/repositories/to-do.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
AuditRepositoryMixin,
IAuditMixinOptions,
} from '@sourceloop/audit-log';
import {AuthenticationBindings, IAuthUser} from 'loopback4-authentication';
import {IAuthUserWithPermissions} from '@sourceloop/core';
import {AuthenticationBindings} from 'loopback4-authentication';
import {PgDataSource} from '../datasources';
import {ToDo, ToDoWithRelations} from '../models';

Expand All @@ -30,7 +31,7 @@ export class ToDoRepository extends AuditRepositoryMixin<
constructor(
@inject(`datasources.${AuditDbSourceName}`) dataSource: PgDataSource,
@inject.getter(AuthenticationBindings.CURRENT_USER)
public getCurrentUser: Getter<IAuthUser>,
public getCurrentUser: Getter<IAuthUserWithPermissions>,
@repository.getter('AuditLogRepository')
public getAuditLogRepository: Getter<AuditLogRepository>,
) {
Expand Down
2 changes: 0 additions & 2 deletions sandbox/auth-ms-basic-example/.npmrc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,52 @@ var path = require('path');
var Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '20221122072057-updated-init-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.up = function (db) {
var filePath = path.join(
__dirname,
'sqls',
'20221122072057-updated-init-up.sql',
);
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20221122072057-updated-init-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.down = function (db) {
var filePath = path.join(
__dirname,
'sqls',
'20221122072057-updated-init-down.sql',
);
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
version: 1,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
DataObject,
HasManyRepositoryFactory,
HasOneRepositoryFactory,
juggler,
Options,
juggler,
repository,
} from '@loopback/repository';
import {HttpErrors} from '@loopback/rest';
Expand All @@ -22,15 +22,15 @@ import {
UserTenantRepository,
} from '@sourceloop/authentication-service';
import {
AuthenticateErrorKeys,
AuthProvider,
AuthenticateErrorKeys,
DefaultSoftCrudRepository,
ILogger,
LOGGER,
UserStatus,
} from '@sourceloop/core';
import {AuthErrorKeys} from 'loopback4-authentication';
import * as bcrypt from 'bcrypt';
import {AuthErrorKeys} from 'loopback4-authentication';

const saltRounds = 10;

Expand Down Expand Up @@ -125,6 +125,7 @@ export class UserRepository extends DefaultSoftCrudRepository<
if (!user || user.deleted) {
throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist);
} else if (
// eslint-disable-next-line
!creds ||
!creds.password ||
creds.authProvider !== AuthProvider.INTERNAL ||
Expand All @@ -144,6 +145,7 @@ export class UserRepository extends DefaultSoftCrudRepository<
): Promise<User> {
const user = await super.findOne({where: {username}});
const creds = user && (await this.credentials(user.id).get());
// eslint-disable-next-line
if (!user || user.deleted || !creds || !creds.password) {
throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist);
} else if (creds.authProvider !== AuthProvider.INTERNAL) {
Expand Down Expand Up @@ -186,7 +188,7 @@ export class UserRepository extends DefaultSoftCrudRepository<
AuthenticateErrorKeys.PasswordCannotBeChanged,
);
}

// eslint-disable-next-line
if (!user || user.deleted || !creds || !creds.password) {
throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist);
} else if (await bcrypt.compare(newPassword, creds.password)) {
Expand Down
2 changes: 0 additions & 2 deletions sandbox/auth-multitenant-example/.npmrc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,52 @@ var path = require('path');
var Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '20221123082705-updated-init-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.up = function (db) {
var filePath = path.join(
__dirname,
'sqls',
'20221123082705-updated-init-up.sql',
);
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20221123082705-updated-init-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
exports.down = function (db) {
var filePath = path.join(
__dirname,
'sqls',
'20221123082705-updated-init-down.sql',
);
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
version: 1,
};
2 changes: 1 addition & 1 deletion sandbox/auth-multitenant-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"eslint:fix": "npm run eslint -- --fix",
"openapi-spec": "npm run build && node ./dist/openapi-spec",
"pretest": "npm run clean && npm run build",
"test": "lb-mocha --allow-console-logs \"dist/__tests__\"",
"test": "echo 'No Tests'",
"posttest": "npm run lint",
"test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest",
"docker:build": "docker build -t auth-multitenant-example .",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class HomePageController {
responses: {
[STATUS_CODE.OK]: {
description: 'Home Page',
// eslint-disable-next-line @typescript-eslint/naming-convention

content: {'text/html': {schema: {type: 'string'}}},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ export class UserExtRepository extends DefaultSoftCrudRepository<
async verifyPassword(username: string, password: string): Promise<User> {
const user = await super.findOne({where: {username}});
const creds = user && (await this.credentials(user.id).get());
if (!user || user.deleted || !creds || !creds.password) {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (!user || user.deleted || !creds?.password) {
throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist);
} else if (!(await bcrypt.compare(password, creds.password))) {
throw new HttpErrors.Unauthorized(AuthErrorKeys.InvalidCredentials);
Expand All @@ -162,7 +163,8 @@ export class UserExtRepository extends DefaultSoftCrudRepository<
): Promise<User> {
const user = await super.findOne({where: {username}});
const creds = user && (await this.credentials(user.id).get());
if (!user || user.deleted || !creds || !creds.password) {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (!user || user.deleted || !creds?.password) {
throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist);
} else if (!(await bcrypt.compare(password, creds.password))) {
throw new HttpErrors.Unauthorized(AuthErrorKeys.WrongPassword);
Expand Down
28 changes: 13 additions & 15 deletions sandbox/cache-example/migrations/20220620093215-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,44 @@ var path = require('path');
var Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function(db) {
exports.up = function (db) {
var filePath = path.join(__dirname, 'sqls', '20220620093215-init-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports.down = function(db) {
exports.down = function (db) {
var filePath = path.join(__dirname, 'sqls', '20220620093215-init-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
}).then(function (data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
version: 1,
};
2 changes: 1 addition & 1 deletion sandbox/cache-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"eslint": "eslint --report-unused-disable-directives .",
"eslint:fix": "npm run eslint -- --fix",
"pretest": "npm run rebuild",
"test": "lb-mocha --allow-console-logs \"dist/__tests__\"",
"test": "echo 'No Tests'",
"posttest": "npm run lint",
"test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest",
"docker:build": "docker build -t @sourceloop/cache-example .",
Expand Down
1 change: 1 addition & 0 deletions sandbox/cache-example/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
// eslint-disable-next-line @typescript-eslint/naming-convention
export const enum STATUS_CODE {
OK = 200,
NO_CONTENT = 204,
Expand Down
2 changes: 0 additions & 2 deletions sandbox/feature-toggle-example/.npmrc

This file was deleted.

Loading

0 comments on commit 2ac3311

Please sign in to comment.