Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .eslintignore

This file was deleted.

67 changes: 0 additions & 67 deletions .eslintrc.json

This file was deleted.

10 changes: 5 additions & 5 deletions src/cli/domain/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default function registry(opts: RegistryOptions = {}) {
requestsHeaders = Object.assign(requestsHeaders, {
Authorization: `Bearer ${options.token}`
});
} else if (!!options.username && !!options.password) {
} else if (options.username && options.password) {
requestsHeaders = Object.assign(requestsHeaders, {
Authorization:
'Basic ' +
Expand All @@ -119,12 +119,12 @@ export default function registry(opts: RegistryOptions = {}) {
} catch {}
}

if (!!parsedError.code && parsedError.code === 'ECONNREFUSED') {
if (parsedError.code && parsedError.code === 'ECONNREFUSED') {
errMsg = 'Connection to registry has not been established';
} else if (
parsedError.code !== 'cli_version_not_valid' &&
parsedError.code !== 'node_version_not_valid' &&
!!parsedError.error
parsedError.error
) {
errMsg = parsedError.error;
} else {
Expand Down Expand Up @@ -176,12 +176,12 @@ export default function registry(opts: RegistryOptions = {}) {
} catch {}
}

if (!!parsedError.code && parsedError.code === 'ECONNREFUSED') {
if (parsedError.code && parsedError.code === 'ECONNREFUSED') {
errMsg = 'Connection to registry has not been established';
} else if (
parsedError.code !== 'cli_version_not_valid' &&
parsedError.code !== 'node_version_not_valid' &&
!!parsedError.error
parsedError.error
) {
errMsg = parsedError.error;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/facade/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const dev = ({ local, logger }: { logger: Logger; local: Local }) =>
logger.ok('OK');
} catch (error: any) {
const errorDescription =
error instanceof SyntaxError || !!error.message
error instanceof SyntaxError || error.message
? error.message
: error;
logger.err(
Expand Down
2 changes: 1 addition & 1 deletion src/cli/facade/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const publish = ({
logger.ok(strings.messages.cli.PUBLISHED(options.route, dryRun));
} catch (err: any) {
if (err === 'Unauthorized' || err.message === 'Unauthorized') {
if (!!options.username || !!options.password || !!options.token) {
if (options.username || options.password || options.token) {
logger.err(
strings.errors.cli.PUBLISHING_FAIL(
strings.errors.cli.INVALID_CREDENTIALS
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/nested-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function nestedRenderer(
components: Options[],
options: Options = {}
): Promise<Array<string | Error>> {
if (!components || !components.length) {
if (!components?.length) {
throw new Error(
strings.errors.registry.NESTED_RENDERER_COMPONENTS_IS_NOT_VALID
);
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/url-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function componentPreview(
baseUrl: string
): string {
let href = componentForType(component, baseUrl, 'preview');
if (!!component.parameters && Object.keys(component.parameters).length) {
if (component.parameters && Object.keys(component.parameters).length) {
href += '/?' + querystring.stringify(component.parameters);
} else {
href += '/';
Expand Down
7 changes: 3 additions & 4 deletions src/registry/domain/validators/registry-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ export default function registryConfiguration(

const dependencies = conf.dependencies;

if (!!dependencies && !Array.isArray(dependencies)) {
if (dependencies && !Array.isArray(dependencies)) {
return returnError(
strings.errors.registry.CONFIGURATION_DEPENDENCIES_MUST_BE_ARRAY
);
}

const routes = conf.routes;

if (!!routes && !Array.isArray(routes)) {
if (routes && !Array.isArray(routes)) {
return returnError(
strings.errors.registry.CONFIGURATION_ROUTES_MUST_BE_ARRAY
);
Expand Down Expand Up @@ -88,8 +88,7 @@ export default function registryConfiguration(
// S3 settings should either specify both key/secret or
// skip both when leveraging IAM Role based S3 access from EC2
if (
!conf.s3 ||
!conf.s3.bucket ||
!conf.s3?.bucket ||
!conf.s3.region ||
(conf.s3.key && !conf.s3.secret) ||
(!conf.s3.key && conf.s3.secret)
Expand Down
2 changes: 1 addition & 1 deletion src/registry/routes/component-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function componentInfo(
const isHtmlRequest =
!!req.headers.accept && req.headers.accept.indexOf('text/html') >= 0;

if (isHtmlRequest && !!res.conf.discovery.ui) {
if (isHtmlRequest && res.conf.discovery.ui) {
const params = getParams(component);
const parsedAuthor = getParsedAuthor(component);
let href = res.conf.baseUrl;
Expand Down
35 changes: 0 additions & 35 deletions src/registry/routes/helpers/format-error-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,38 +169,3 @@ function getCodeFrame(
return null;
}
}

// async function main() {
// const stackTrace = `
// TypeError: Cannot read properties of undefined (reading 'name')
// at HandledServer.initial (/Users/ricardo.agullo/Dev/octests/helpai/_package/server.js:196:38)
// at async ocServerWrapper (/Users/ricardo.agullo/Dev/octests/helpai/_package/server.js:83:19)
// `;
// const rawSourceMap = fs.readFileSync(
// './helpai/_package/server.js.map',
// 'utf8'
// );
// const { stack, codeFrame } = await processStackTrace({
// stackTrace,
// rawSourceMap
// });

// // Log the stack trace
// for (const line of stack) {
// console.log(` ${line}`);
// }

// // Log the code frames
// // for (const frame of codeFrame) {
// // console.log(`\n${frame}\n`);
// // }
// for (let i = 0; i < codeFrame.length; i++) {
// if (i === 0) {
// console.log(`\n ${codeFrame[i]}\n`);
// } else {
// console.log(`\n${codeFrame[i]}\n`);
// }
// }
// }

// main().catch(console.error);
6 changes: 3 additions & 3 deletions src/registry/routes/helpers/get-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export default function getComponent(conf: Config, repository: Repository) {
renderMode
});

if (!!err || !data) {
if (err || !data) {
err =
err ||
new Error(strings.errors.registry.DATA_OBJECT_IS_UNDEFINED);
Expand Down Expand Up @@ -521,7 +521,7 @@ export default function getComponent(conf: Config, repository: Repository) {
);
};

if (!!cached && !conf.hotReloading) {
if (cached && !conf.hotReloading) {
returnResult(cached);
} else {
fromPromise(repository.getCompiledView)(
Expand Down Expand Up @@ -642,7 +642,7 @@ export default function getComponent(conf: Config, repository: Repository) {
}
};

if (!!cached && !conf.hotReloading) {
if (cached && !conf.hotReloading) {
domain.on('error', returnComponent);

try {
Expand Down
2 changes: 1 addition & 1 deletion src/registry/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function (repository: Repository) {
)
);

if (isHtmlRequest(req.headers) && !!res.conf.discovery.ui) {
if (isHtmlRequest(req.headers) && res.conf.discovery.ui) {
const processedComponents: ParsedComponent[] = componentDetails.map(
(component) => {
if (component.oc?.date) {
Expand Down
2 changes: 1 addition & 1 deletion src/registry/routes/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { validateTemplateOcVersion } from '../domain/validators';
export default function validate() {
return async (req: Request, res: Response): Promise<void> => {
// Validate that request has a JSON body with package.json
if (!req.body || !req.body.packageJson) {
if (!req.body?.packageJson) {
res.status(400).json({
error: 'Invalid request: packageJson is required in request body'
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/clean-require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function cleanRequire(
) {
const shouldThrow = !justTry;

if (require.cache && !!require.cache[path]) {
if (require.cache?.[path]) {
delete require.cache[path];
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/module-exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import tryRequire from 'try-require';
export default function moduleExists(moduleName: string): boolean {
const packageModulePath = path.join(moduleName, 'package.json');

if (require.cache && !!require.cache[packageModulePath]) {
if (require.cache?.[packageModulePath]) {
delete require.cache[packageModulePath];
}

Expand Down
Loading