Skip to content

Commit e28cc70

Browse files
Merge branch 'master' into reduce-null-assertions
2 parents 4ff9aa1 + 6b156b6 commit e28cc70

File tree

8 files changed

+53
-49
lines changed

8 files changed

+53
-49
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"no-useless-constructor": "error",
6060
"no-useless-return": "error",
6161
"no-warning-comments": "error",
62+
"one-var": ["error", "never"],
6263
"prefer-promise-reject-errors": "error",
6364
"require-await": "error",
6465
"symbol-description": "error"

src/cli/domain/get-components-by-dir.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Component } from '../../types';
55
export default function getComponentsByDir() {
66
return (componentsDir: string, callback: Callback<string[]>): void => {
77
const isOcComponent = function (file: string) {
8-
const filePath = path.resolve(componentsDir, file),
9-
packagePath = path.join(filePath, 'package.json');
8+
const filePath = path.resolve(componentsDir, file);
9+
const packagePath = path.join(filePath, 'package.json');
1010
let content: Component;
1111

1212
try {

src/cli/domain/registry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import * as urlParser from '../domain/url-parser';
1010
import { RegistryCli } from '../../types';
1111

1212
const getOcVersion = (): string => {
13-
const ocPackagePath = path.join(__dirname, '../../../package.json'),
14-
ocInfo = fs.readJsonSync(ocPackagePath);
13+
const ocPackagePath = path.join(__dirname, '../../../package.json');
14+
const ocInfo = fs.readJsonSync(ocPackagePath);
1515

1616
return ocInfo.version;
1717
};

src/cli/domain/url-parser.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,19 @@ export function parse(parsed: {
2020
requestVersion: string;
2121
href: string;
2222
}): UrlParsed {
23-
const requestedVersion = parsed.requestVersion,
24-
href = url.parse(parsed.href),
25-
relativePath = removeFinalSlashes(href.pathname || ''),
26-
withoutVersion = removeFinalSlashes(
27-
relativePath.replace(requestedVersion, '')
28-
),
29-
componentName = withoutVersion.substr(withoutVersion.lastIndexOf('/') + 1),
30-
withoutComponent = removeFinalSlashes(
31-
withoutVersion.replace(componentName, '')
32-
),
33-
registryUrl = href.protocol + '//' + href.host + withoutComponent + '/';
23+
const requestedVersion = parsed.requestVersion;
24+
const href = url.parse(parsed.href);
25+
const relativePath = removeFinalSlashes(href.pathname || '');
26+
const withoutVersion = removeFinalSlashes(
27+
relativePath.replace(requestedVersion, '')
28+
);
29+
const componentName = withoutVersion.substr(
30+
withoutVersion.lastIndexOf('/') + 1
31+
);
32+
const withoutComponent = removeFinalSlashes(
33+
withoutVersion.replace(componentName, '')
34+
);
35+
const registryUrl = href.protocol + '//' + href.host + withoutComponent + '/';
3436

3537
return {
3638
clientHref: registryUrl + 'oc-client/client.js',

src/cli/facade/package.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ const cliPackage =
1414
},
1515
callback: Callback<Component, string>
1616
): void => {
17-
const componentPath = opts.componentPath,
18-
useComponentDependencies = opts.useComponentDependencies,
19-
packageDir = path.resolve(componentPath, '_package'),
20-
compressedPackagePath = path.resolve(componentPath, 'package.tar.gz');
17+
const componentPath = opts.componentPath;
18+
const useComponentDependencies = opts.useComponentDependencies;
19+
const packageDir = path.resolve(componentPath, '_package');
20+
const compressedPackagePath = path.resolve(componentPath, 'package.tar.gz');
2121

2222
logger.warn(strings.messages.cli.PACKAGING(packageDir));
2323
handleDependencies(

src/cli/facade/publish.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ const publish =
2929
},
3030
callback: (err?: Error | string) => void
3131
): void => {
32-
const componentPath = opts.componentPath,
33-
skipPackage = opts.skipPackage,
34-
packageDir = path.resolve(componentPath, '_package'),
35-
compressedPackagePath = path.resolve(componentPath, 'package.tar.gz');
32+
const componentPath = opts.componentPath;
33+
const skipPackage = opts.skipPackage;
34+
const packageDir = path.resolve(componentPath, '_package');
35+
const compressedPackagePath = path.resolve(componentPath, 'package.tar.gz');
3636

3737
let errorMessage;
3838

@@ -115,9 +115,10 @@ const publish =
115115
});
116116
} else if ((err as any).code === 'cli_version_not_valid') {
117117
const upgradeCommand = strings.commands.cli.UPGRADE(
118-
(err as any).details.suggestedVersion
119-
),
120-
errorDetails = strings.errors.cli.OC_CLI_VERSION_NEEDS_UPGRADE(
118+
(err as any).details.suggestedVersion
119+
);
120+
const errorDetails =
121+
strings.errors.cli.OC_CLI_VERSION_NEEDS_UPGRADE(
121122
colors.blue(upgradeCommand)
122123
);
123124

@@ -156,8 +157,8 @@ const publish =
156157
async.eachSeries(
157158
registryLocations,
158159
(registryUrl, next) => {
159-
const registryNormalised = registryUrl.replace(/\/$/, ''),
160-
componentRoute = `${registryNormalised}/${component.name}/${component.version}`;
160+
const registryNormalised = registryUrl.replace(/\/$/, '');
161+
const componentRoute = `${registryNormalised}/${component.name}/${component.version}`;
161162
putComponentToRegistry(
162163
{ route: componentRoute, path: compressedPackagePath },
163164
next as any

src/registry/routes/helpers/get-component.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ export type GetComponentResult = {
5252
};
5353

5454
export default function getComponent(conf: Config, repository: Repository) {
55-
const client = Client({ templates: conf.templates }),
56-
cache = new Cache({
57-
verbose: !!conf.verbosity,
58-
refreshInterval: conf.refreshInterval
59-
});
55+
const client = Client({ templates: conf.templates });
56+
const cache = new Cache({
57+
verbose: !!conf.verbosity,
58+
refreshInterval: conf.refreshInterval
59+
});
6060

6161
const renderer = function (
6262
options: Options,
6363
cb: (result: GetComponentResult) => void
6464
) {
65-
const nestedRenderer = NestedRenderer(renderer, options.conf),
66-
retrievingInfo = GetComponentRetrievingInfo(options);
65+
const nestedRenderer = NestedRenderer(renderer, options.conf);
66+
const retrievingInfo = GetComponentRetrievingInfo(options);
6767
let responseHeaders: Dictionary<string> = {};
6868

6969
const getLanguage = () => {
@@ -155,18 +155,18 @@ export default function getComponent(conf: Config, repository: Repository) {
155155

156156
// sanitise and check params
157157
const appliedParams = applyDefaultValues(
158-
requestedComponent.parameters,
159-
component.oc.parameters
160-
),
161-
params = sanitiser.sanitiseComponentParameters(
162-
appliedParams,
163-
component.oc.parameters
164-
),
165-
validationResult = validator.validateComponentParameters(
166-
// @ts-ignore
167-
params,
168-
component.oc.parameters
169-
);
158+
requestedComponent.parameters,
159+
component.oc.parameters
160+
);
161+
const params = sanitiser.sanitiseComponentParameters(
162+
appliedParams,
163+
component.oc.parameters
164+
);
165+
const validationResult = validator.validateComponentParameters(
166+
// @ts-ignore
167+
params,
168+
component.oc.parameters
169+
);
170170

171171
if (!validationResult.isValid) {
172172
return callback({

src/registry/routes/static-redirector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export default function staticRedirector(repository: Repository) {
5656
return;
5757
}
5858

59-
const fileStream = fs.createReadStream(filePath),
60-
fileInfo = getFileInfo(filePath);
59+
const fileStream = fs.createReadStream(filePath);
60+
const fileInfo = getFileInfo(filePath);
6161

6262
if (fileInfo.mimeType) {
6363
res.set('Content-Type', fileInfo.mimeType);

0 commit comments

Comments
 (0)