Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
thymikee committed Sep 15, 2019
1 parent efd31d5 commit f82c1cb
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 34 deletions.
9 changes: 2 additions & 7 deletions packages/cli/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@ import {Command} from '@react-native-community/cli-types';

// @ts-ignore - JS file
import server from './server/server';
// @ts-ignore - JS file
import bundle from './bundle/bundle';
// @ts-ignore - JS file
import ramBundle from './bundle/ramBundle';
// @ts-ignore - JS file
import link from './link/link'; // eslint-disable-line import/namespace, import/default
// @ts-ignore - JS file
import unlink from './link/unlink'; // eslint-disable-line import/namespace, import/default
import link from './link/link';
import unlink from './link/unlink';
import install from './install/install';
import uninstall from './install/uninstall';
import upgrade from './upgrade/upgrade';
import info from './info/info';
import config from './config/config';
// @ts-ignore - JS file
import init from './init';
// @ts-ignore - JS file
import doctor from './doctor';
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/install/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
*/
import {logger} from '@react-native-community/cli-tools';
import * as PackageManager from '../../tools/packageManager';
// @ts-ignore FIXME after converting link/link
import link from '../link/link'; // eslint-disable-line import/namespace, import/default
import link from '../link/link';
// @ts-ignore FIXME after converting tools/config
import loadConfig from '../../tools/config'; // eslint-disable-line import/namespace, import/default

Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/install/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import {Config} from '@react-native-community/cli-types';
import {logger} from '@react-native-community/cli-tools';
import * as PackageManager from '../../tools/packageManager';
// @ts-ignore FIXME after converting link/unlink
import unlink from '../link/unlink'; // eslint-disable-line import/namespace, import/default
import unlink from '../link/unlink';

async function uninstall(args: Array<string>, ctx: Config): Promise<void> {
const name = args[0];
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/link/__tests__/link-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {func as link} from '../link';
import loadConfig from '../../../tools/config';
import loadConfig from '../../../tools/config'; // eslint-disable-line import/namespace, import/default
import makeHook from '../makeHook';
jest.mock('chalk', () => ({grey: str => str, bold: str => str}));
jest.mock('../../../tools/config');
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/commands/link/__tests__/makeHook-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ afterAll(() => {
describe('makeHook', () => {
it('invokes the command', async () => {
const hook = makeHook('echo');
// $FlowFixMe - execa weird Promise-like return value
const result = await hook();
expect(result.cmd).toBe('echo');
});

it('invokes the command with multiple arguments', async () => {
const hook = makeHook('node -p "1;"');
// $FlowFixMe - execa weird Promise-like return value
const result = await hook();
expect(result.cmd).toBe('node -p "1;"');
});
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/link/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const link = async (
let project = ctx.project;

if (opts.platforms) {
// @ts-ignore
platforms = pick(platforms, opts.platforms);
logger.debug('Skipping selected platforms');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/link/linkAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const linkAll = async (
),
);
try {
await linkAssets(config.platforms, config.project, assets);
linkAssets(config.platforms, config.project, assets);
} catch (error) {
throw new CLIError('Linking assets failed.', error);
}
Expand Down
10 changes: 4 additions & 6 deletions packages/cli/src/commands/link/linkAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import {isEmpty} from 'lodash';
import {Config} from '@react-native-community/cli-types';
import {logger} from '@react-native-community/cli-tools';

const linkAssets = (
export default function linkAssets(
platforms: Config['platforms'],
project: Config['project'],
assets: Array<string>,
): void => {
): void {
if (isEmpty(assets)) {
return;
}
Expand All @@ -22,11 +22,9 @@ const linkAssets = (
}

logger.info(`Linking assets to ${platform} project`);
// $FlowFixMe: We check for existence of project[platform]

linkConfig.copyAssets(assets, project[platform]);
});

logger.success('Assets have been successfully linked to your project');
};

export default linkAssets;
}
12 changes: 4 additions & 8 deletions packages/cli/src/commands/link/linkDependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {logger} from '@react-native-community/cli-tools';
import pollParams from './pollParams';
import {getPlatformName} from './getPlatformName';

const linkDependency = async (
export default async function linkDependency(
platforms: Config['platforms'],
project: Config['project'],
dependency: Config['dependencies']['key'],
): Promise<void | null> => {
): Promise<void | null> {
const params = await pollParams(dependency.params);

Object.keys(platforms || {}).forEach(platform => {
Expand All @@ -34,10 +34,8 @@ const linkDependency = async (
}

const isInstalled = linkConfig.isInstalled(
// $FlowFixMe
projectConfig,
name,
// $FlowFixMe
dependencyConfig,
);

Expand All @@ -53,7 +51,7 @@ const linkDependency = async (
logger.info(
`Linking "${chalk.bold(name)}" ${getPlatformName(platform)} dependency`,
);
// $FlowFixMe

linkConfig.register(name, dependencyConfig, params, projectConfig);

logger.info(
Expand All @@ -62,6 +60,4 @@ const linkDependency = async (
)}" has been successfully linked`,
);
});
};

export default linkDependency;
}
7 changes: 2 additions & 5 deletions packages/cli/src/commands/link/unlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ const unlinkDependency = (
}

const isInstalled = linkConfig.isInstalled(
// $FlowFixMe
projectConfig,
packageName,
// $FlowFixMe
dependencyConfig,
);

Expand All @@ -65,9 +63,7 @@ const unlinkDependency = (

linkConfig.unregister(
packageName,
// $FlowFixMe
dependencyConfig,
// $FlowFixMe
projectConfig,
otherDependencies,
);
Expand Down Expand Up @@ -95,6 +91,7 @@ const unlink = async (
let platforms = ctx.platforms;

if (opts.platforms) {
// @ts-ignore
platforms = pick(platforms, opts.platforms);
logger.debug('Skipping selected platforms');
}
Expand Down Expand Up @@ -159,7 +156,7 @@ const unlink = async (
}

logger.info(`Unlinking assets from ${platform} project`);
// $FlowFixMe

linkConfig.unlinkAssets(assets, projectConfig);
});

Expand Down

0 comments on commit f82c1cb

Please sign in to comment.