Skip to content

Commit 5807915

Browse files
Merge branch 'master' into registries-option-on-publish
2 parents f41803b + cd830d1 commit 5807915

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+275
-183
lines changed

src/cli/domain/clean.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@ import path from 'path';
55

66
const getComponentsByDir = makeGetComponentsByDir();
77

8-
export function fetchList(dirPath: string, callback: Callback<string[]>): void {
8+
export function fetchList(
9+
dirPath: string,
10+
callback: (err: Error | null, data: string[]) => void
11+
): void {
912
return getComponentsByDir(dirPath, (err, list) => {
1013
if (err) return (callback as any)(err);
1114
if (list.length === 0) return callback(null, []);
1215

1316
const toRemove = list.map(folder => path.join(folder, 'node_modules'));
14-
const folderExists = (folder: string, cb: Callback<boolean>) =>
15-
fs.exists(folder, exists => cb(null, exists));
17+
const folderExists = (
18+
folder: string,
19+
cb: (err: Error | null, data: boolean) => void
20+
) => fs.exists(folder, exists => cb(null, exists));
1621

1722
async.filterSeries(toRemove, folderExists, callback as any);
1823
});
1924
}
2025

21-
export function remove(list: string[], callback: Callback<string>): void {
26+
export function remove(
27+
list: string[],
28+
callback: (err: Error | null, data: string) => void
29+
): void {
2230
return async.eachSeries(list, fs.remove, callback as any);
2331
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import path from 'path';
33
import { Component } from '../../types';
44

55
export default function getComponentsByDir() {
6-
return (componentsDir: string, callback: Callback<string[]>): void => {
6+
return (
7+
componentsDir: string,
8+
callback: (err: Error | null, data: string[]) => void
9+
): void => {
710
const isOcComponent = function (file: string) {
811
const filePath = path.resolve(componentsDir, file);
912
const packagePath = path.join(filePath, 'package.json');

src/cli/domain/get-mocked-plugins.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const defaultRegister = (
4545
};
4646

4747
const registerStaticMocks = (
48-
mocks: Dictionary<string>,
48+
mocks: Record<string, string>,
4949
logger: Logger
5050
): PluginMock[] =>
5151
_.map(mocks, (mockedValue, pluginName) => {
@@ -62,7 +62,7 @@ const registerStaticMocks = (
6262

6363
const registerDynamicMocks = (
6464
ocJsonLocation: string,
65-
mocks: Dictionary<string>,
65+
mocks: Record<string, string>,
6666
logger: Logger
6767
) =>
6868
_.map(mocks, (source, pluginName) => {

src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function ensureCompilerIsDeclaredAsDevDependency(
77
pkg: Component;
88
template: string;
99
},
10-
cb: Callback<string, string>
10+
cb: (err: string | null, data: string) => void
1111
): void {
1212
const { componentPath, pkg, template } = options;
1313
const compilerDep = `${template}-compiler`;

src/cli/domain/handle-dependencies/get-compiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export default function getCompiler(
1010
compilerDep: string;
1111
componentPath: string;
1212
logger: Logger;
13-
pkg: { devDependencies: Dictionary<string> };
13+
pkg: { devDependencies: Record<string, string> };
1414
},
15-
cb: Callback<Template, string | number>
15+
cb: (err: string | number | null, data: Template) => void
1616
): void {
1717
const { compilerDep, componentPath, logger, pkg } = options;
1818
const compilerPath = path.join(componentPath, 'node_modules', compilerDep);

src/cli/domain/handle-dependencies/index.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Component } from '../../../types';
1414

1515
const getComponentPackageJson = (
1616
componentPath: string,
17-
cb: Callback<Component>
17+
cb: (err: Error | null, data: Component) => void
1818
) => fs.readJson(path.join(componentPath, 'package.json'), cb);
1919

2020
const union = (a: ReadonlyArray<string>, b: ReadonlyArray<string>) => [
@@ -27,25 +27,25 @@ export default function handleDependencies(
2727
logger: Logger;
2828
useComponentDependencies?: boolean;
2929
},
30-
callback: Callback<
31-
{
30+
callback: (
31+
err: string | null,
32+
data: {
3233
modules: string[];
3334
templates: Array<(...args: unknown[]) => unknown>;
34-
},
35-
string
36-
>
35+
}
36+
) => void
3737
): void {
3838
const { components, logger, useComponentDependencies } = options;
3939

40-
const dependencies: Dictionary<string> = {};
41-
const addDependencies = (componentDependencies?: Dictionary<string>) =>
40+
const dependencies: Record<string, string> = {};
41+
const addDependencies = (componentDependencies?: Record<string, string>) =>
4242
Object.entries(componentDependencies || {}).forEach(
4343
([dependency, version]) => {
4444
dependencies[dependency] = version;
4545
}
4646
);
4747

48-
const templates: Dictionary<(...args: unknown[]) => unknown> = {};
48+
const templates: Record<string, (...args: unknown[]) => unknown> = {};
4949
const addTemplate = (
5050
templateName: string,
5151
template: (...args: unknown[]) => unknown
@@ -59,15 +59,19 @@ export default function handleDependencies(
5959
) =>
6060
async.waterfall(
6161
[
62-
(cb: Callback<Component>) => getComponentPackageJson(componentPath, cb),
62+
(cb: (err: Error | null, data: Component) => void) =>
63+
getComponentPackageJson(componentPath, cb),
6364
(
6465
pkg: Component,
65-
cb: Callback<{
66-
componentPath: string;
67-
logger: Logger;
68-
pkg: Component;
69-
template: string;
70-
}>
66+
cb: (
67+
err: Error | null,
68+
data: {
69+
componentPath: string;
70+
logger: Logger;
71+
pkg: Component;
72+
template: string;
73+
}
74+
) => void
7175
) => {
7276
addDependencies(pkg.dependencies);
7377

@@ -96,7 +100,7 @@ export default function handleDependencies(
96100
options: {
97101
componentPath: string;
98102
logger: Logger;
99-
pkg: Component & { devDependencies: Dictionary<string> };
103+
pkg: Component & { devDependencies: Record<string, string> };
100104
template: string;
101105
compilerDep: string;
102106
},

src/cli/domain/handle-dependencies/install-compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function installCompiler(
1212
dependency: string;
1313
logger: Logger;
1414
},
15-
cb: Callback<Template, string | number>
15+
cb: (err: string | number | null, data: Template) => void
1616
): void {
1717
const { compilerPath, componentPath, dependency, logger } = options;
1818

src/cli/domain/handle-dependencies/install-missing-dependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import strings from '../../../resources/index';
66
import { Logger } from '../../logger';
77

88
export default function installMissingDependencies(
9-
options: { dependencies: Dictionary<string>; logger: Logger },
9+
options: { dependencies: Record<string, string>; logger: Logger },
1010
callback: (err: string | null) => void
1111
): void {
1212
const { dependencies, logger } = options;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Logger } from '../../logger';
88
export default function linkMissingDependencies(
99
options: {
1010
componentPath: string;
11-
dependencies: Dictionary<string>;
11+
dependencies: Record<string, string>;
1212
logger: Logger;
1313
},
1414
callback: (err: string | null) => void

src/cli/domain/handle-dependencies/require-template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface Template {
1717
verbose: boolean;
1818
production: boolean | undefined;
1919
},
20-
cb: Callback<Component>
20+
cb: (err: Error | null, data: Component) => void
2121
) => void;
2222
}
2323

0 commit comments

Comments
 (0)