Skip to content

Commit 3bab121

Browse files
type Registry, some routes and refine return types on some files
1 parent ff58725 commit 3bab121

21 files changed

+401
-242
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
22
import path from 'path';
33

44
export default function getComponentsByDir() {
5-
return function(componentsDir: string, callback: Callback<string[]>) {
5+
return (componentsDir: string, callback: Callback<string[]>): void => {
66
const isOcComponent = function(file: string) {
77
const filePath = path.resolve(componentsDir, file),
88
packagePath = path.join(filePath, 'package.json');

src/cli/domain/handle-dependencies/link-missing-dependencies.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ module.exports = (options, callback) => {
3535
fs.ensureSymlinkSync(pathToComponentModule, pathToModule, symLinkType);
3636
} catch (err) {
3737
symLinkError = true;
38-
logger.err(strings.errors.cli.DEPENDENCY_LINK_FAIL(moduleName, err));
38+
logger.err(
39+
strings.errors.cli.DEPENDENCY_LINK_FAIL(moduleName, String(err))
40+
);
3941
}
4042
});
4143
return !symLinkError

src/cli/domain/init-template/scaffold.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface ScaffoldOptions {
1414
export default function scaffold(
1515
options: ScaffoldOptions,
1616
callback: Callback<{ ok: true }, string>
17-
) {
17+
): void {
1818
const {
1919
compiler,
2020
compilerPath,
@@ -25,14 +25,14 @@ export default function scaffold(
2525

2626
const baseComponentPath = path.join(compilerPath, 'scaffold');
2727
const baseComponentFiles = path.join(baseComponentPath, 'src');
28-
const compilerPackage = fs.readJSONSync(
28+
const compilerPackage = fs.readJsonSync(
2929
path.join(compilerPath, 'package.json')
3030
);
3131

3232
try {
3333
fs.copySync(baseComponentFiles, componentPath);
3434

35-
const componentPackage = fs.readJSONSync(
35+
const componentPackage = fs.readJsonSync(
3636
path.join(componentPath, 'package.json')
3737
);
3838
componentPackage.name = componentName;
@@ -46,6 +46,8 @@ export default function scaffold(
4646
const url =
4747
(compilerPackage.bugs && compilerPackage.bugs.url) ||
4848
`the ${templateType} repo`;
49-
return (callback as any)(strings.errors.cli.scaffoldError(url, error));
49+
return (callback as any)(
50+
strings.errors.cli.scaffoldError(url, String(error))
51+
);
5052
}
5153
}

src/cli/validate-command.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import strings from '../resources';
55
export default function validateCommand(argv: Arguments, level: number): true {
66
let keys = Object.keys(commands.commands);
77
if (level === 1) {
8-
keys = Object.keys(commands.commands[argv._[0]].commands || {});
8+
keys = Object.keys((commands as any).commands[argv._[0]].commands || {});
99
}
1010

11-
if (argv._.length > level && !keys.includes(argv._[String(level)])) {
12-
throw new Error(strings.messages.cli.NO_SUCH_COMMAND(argv._[level]));
11+
if (argv._.length > level && !keys.includes((argv as any)._[String(level)])) {
12+
throw new Error(
13+
strings.messages.cli.NO_SUCH_COMMAND(String(argv._[level]))
14+
);
1315
}
1416

1517
return true;

src/registry/app-start.js renamed to src/registry/app-start.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
'use strict';
1+
import colors from 'colors/safe';
2+
import path from 'path';
3+
import _ from 'lodash';
4+
import fs from 'fs-extra';
5+
import { ComponentsDetails, Config, Repository } from '../types';
26

3-
const colors = require('colors/safe');
4-
const path = require('path');
5-
const _ = require('lodash');
7+
const packageInfo = fs.readJsonSync(
8+
path.join(
9+
__dirname,
10+
'..',
11+
'components',
12+
'oc-client',
13+
'_package',
14+
'package.json'
15+
)
16+
);
617

7-
// @ts-ignore
8-
const packageInfo = require('../components/oc-client/_package/package');
9-
10-
module.exports = function(repository, options, callback) {
18+
export default function appStart(
19+
repository: Repository,
20+
options: Config,
21+
callback: Callback<ComponentsDetails | string, any>
22+
): void {
1123
if (options.local) {
1224
return callback(null, 'ok');
1325
}
@@ -50,7 +62,9 @@ module.exports = function(repository, options, callback) {
5062
if (!err) {
5163
logger.log(colors.green('Component published.'));
5264
} else {
53-
logger.log(colors.red(`Component not published: ${err.message}`));
65+
logger.log(
66+
colors.red(`Component not published: ${(err as any).message}`)
67+
);
5468
}
5569

5670
callback(err, res);
@@ -61,4 +75,4 @@ module.exports = function(repository, options, callback) {
6175
callback(null, 'ok');
6276
}
6377
});
64-
};
78+
}

src/registry/domain/extract-package.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import targz from 'targz';
44
import getPackageJsonFromTempDir from './get-package-json-from-temp-dir';
55

66
export default function extractPackage(
7-
files: Express.Multer.File[],
7+
files:
8+
| Express.Multer.File[]
9+
| {
10+
[fieldname: string]: Express.Multer.File[];
11+
},
812
callback: Callback<{
913
outputFolder: string;
1014
packageJson: any;

src/registry/domain/nested-renderer.js

Lines changed: 0 additions & 120 deletions
This file was deleted.

0 commit comments

Comments
 (0)