Skip to content

Commit f618364

Browse files
Extract local type from function that creates it
1 parent 201491c commit f618364

File tree

10 files changed

+23
-45
lines changed

10 files changed

+23
-45
lines changed

src/cli/domain/local.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import mock from './mock';
1010
import packageComponents from './package-components';
1111
import strings from '../../resources';
1212
import * as validator from '../../registry/domain/validators';
13-
import { Local } from '../../types';
13+
import { Logger } from '../logger';
1414

15-
export default function local(): Local {
15+
export default function local() {
1616
return {
1717
clean,
18-
cleanup(compressedPackagePath: string) {
18+
cleanup(compressedPackagePath: string): Promise<void> {
1919
return fs.unlink(compressedPackagePath);
2020
},
21-
compress(input, output) {
21+
compress(input: string, output: string): Promise<void> {
2222
return promisify(targz.compress)({
2323
src: input,
2424
dest: output,
@@ -32,7 +32,12 @@ export default function local(): Local {
3232
});
3333
},
3434
getComponentsByDir: getComponentsByDir(),
35-
async init(options) {
35+
async init(options: {
36+
componentName: string;
37+
logger: Logger;
38+
componentPath: string;
39+
templateType: string;
40+
}): Promise<void> {
3641
const { componentName, logger } = options;
3742
let { templateType } = options;
3843
if (!validator.validateComponentName(componentName)) {
@@ -68,3 +73,5 @@ export default function local(): Local {
6873
package: packageComponents()
6974
};
7075
}
76+
77+
export type Local = ReturnType<typeof local>;

src/cli/domain/package-components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import requireTemplate from './handle-dependencies/require-template';
66
import * as validator from '../../registry/domain/validators';
77
import { Component } from '../../types';
88

9-
interface PackageOptions {
9+
export interface PackageOptions {
1010
componentPath: string;
1111
minify?: boolean;
1212
verbose?: boolean;

src/cli/facade/clean.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import readCb from 'read';
22
import { fromPromise } from 'universalify';
33
import { promisify } from 'util';
44
import strings from '../../resources/index';
5-
import { Local } from '../../types';
5+
import type { Local } from '../domain/local';
66
import { Logger } from '../logger';
77

88
const read = promisify(readCb);

src/cli/facade/dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as oc from '../../index';
1111
import strings from '../../resources/index';
1212
import watch from '../domain/watch';
1313
import { Logger } from '../logger';
14-
import { Local } from '../../types';
14+
import type { Local } from '../domain/local';
1515

1616
type Registry = ReturnType<typeof oc.Registry>;
1717

src/cli/facade/init.ts

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

44
import strings from '../../resources/index';
5-
import { Local } from '../../types';
5+
import type { Local } from '../domain/local';
66
import { Logger } from '../logger';
77

88
const init = ({ local, logger }: { local: Local; logger: Logger }) =>

src/cli/facade/mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fromPromise } from 'universalify';
22
import strings from '../../resources/index';
3-
import { Local } from '../../types';
3+
import type { Local } from '../domain/local';
44
import { Logger } from '../logger';
55

66
const mock = ({ local, logger }: { local: Local; logger: Logger }) =>

src/cli/facade/package.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import path from 'path';
33
import { fromPromise } from 'universalify';
44
import handleDependencies from '../domain/handle-dependencies';
55
import { Logger } from '../logger';
6-
import { Component, Local } from '../../types';
6+
import type { Local } from '../domain/local';
7+
import { Component } from '../../types';
78

89
const cliPackage = ({ local, logger }: { local: Local; logger: Logger }) =>
910
fromPromise(

src/cli/facade/publish.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import fs from 'fs-extra';
44
import readCb from 'read';
55
import { promisify } from 'util';
66
import { Logger } from '../logger';
7-
import { Component, RegistryCli, Local } from '../../types';
7+
import type { Local } from '../domain/local';
8+
import { Component, RegistryCli } from '../../types';
89
import { fromPromise } from 'universalify';
910

1011
import handleDependencies from '../domain/handle-dependencies';

src/cli/programmatic-api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import local from './domain/local';
1+
import local, { Local } from './domain/local';
22
import { Logger } from './logger';
33
import Registry from './domain/registry';
44

@@ -11,7 +11,7 @@ import preview from './facade/preview';
1111
import registryAdd from './facade/registry-add';
1212
import registryLs from './facade/registry-ls';
1313
import registryRemove from './facade/registry-remove';
14-
import { Local, RegistryCli } from '../types';
14+
import { RegistryCli } from '../types';
1515

1616
type Options<T extends (...args: any) => any> = Parameters<ReturnType<T>>[0];
1717
type Cb<T extends (...args: any) => any> = Parameters<ReturnType<T>>[1];

src/types.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { NextFunction, Request, Response } from 'express';
2-
import { Logger } from './cli/logger';
32
import { PackageJson } from 'type-fest';
43

54
export interface Author {
@@ -250,36 +249,6 @@ export interface RegistryCli {
250249
remove(registry: string): Promise<void>;
251250
}
252251

253-
export interface Local {
254-
clean: {
255-
fetchList: (dirPath: string) => Promise<string[]>;
256-
remove: (list: string[]) => Promise<void>;
257-
};
258-
cleanup: (compressedPackagePath: string) => Promise<void>;
259-
compress: (input: string, output: string) => Promise<void>;
260-
getComponentsByDir: (
261-
componentsDir: string,
262-
componentsToRun?: string[]
263-
) => Promise<string[]>;
264-
init: (options: {
265-
componentName: string;
266-
logger: Logger;
267-
componentPath: string;
268-
templateType: string;
269-
}) => Promise<void>;
270-
mock: (params: {
271-
targetType: string;
272-
targetValue: string;
273-
targetName: string;
274-
}) => Promise<void>;
275-
package: (options: {
276-
componentPath: string;
277-
minify?: boolean;
278-
verbose?: boolean;
279-
production?: boolean;
280-
}) => Promise<Component>;
281-
}
282-
283252
declare global {
284253
// eslint-disable-next-line @typescript-eslint/no-namespace
285254
namespace Express {

0 commit comments

Comments
 (0)