diff --git a/packages/cli/src/commands/dependencies/dependencies.js b/packages/cli/src/commands/dependencies/dependencies.js deleted file mode 100644 index 2004e04e9..000000000 --- a/packages/cli/src/commands/dependencies/dependencies.js +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import Metro from 'metro'; - -import denodeify from 'denodeify'; -import fs from 'fs'; -import path from 'path'; -import util from 'util'; - -async function dependencies(argv, configPromise, args, packagerInstance) { - const rootModuleAbsolutePath = args.entryFile; - const config = await configPromise; - if (!fs.existsSync(rootModuleAbsolutePath)) { - return Promise.reject( - new Error(`File ${rootModuleAbsolutePath} does not exist`), - ); - } - - config.cacheStores = []; - - const relativePath = path.relative( - config.projectRoot, - rootModuleAbsolutePath, - ); - - const options = { - platform: args.platform, - entryFile: relativePath, - dev: args.dev, - minify: false, - generateSourceMaps: !args.dev, - }; - - const writeToFile = args.output; - const outStream = writeToFile - ? fs.createWriteStream(args.output) - : process.stdout; - - const deps = packagerInstance - ? await packagerInstance.getOrderedDependencyPaths(options) - : await Metro.getOrderedDependencyPaths(config, options); - - deps.forEach(modulePath => { - // Temporary hack to disable listing dependencies not under this directory. - // Long term, we need either - // (a) JS code to not depend on anything outside this directory, or - // (b) Come up with a way to declare this dependency in Buck. - const isInsideProjectRoots = - config.watchFolders.filter(root => modulePath.startsWith(root)).length > - 0; - - if (isInsideProjectRoots) { - outStream.write(`${modulePath}\n`); - } - }); - return writeToFile - ? denodeify(outStream.end).bind(outStream)() - : Promise.resolve(); -} - -export default { - name: 'dependencies', - description: 'lists dependencies', - func: util.deprecate( - dependencies, - 'dependencies command was moved to metro, and will be removed from cli in next release', - ), - options: [ - { - command: '--entry-file ', - description: 'Absolute path to the root JS file', - }, - { - command: '--output [path]', - description: - 'File name where to store the output, ex. /tmp/dependencies.txt', - }, - { - command: '--platform [extension]', - description: 'The platform extension used for selecting modules', - }, - { - command: '--transformer [path]', - description: 'Specify a custom transformer to be used', - }, - { - command: '--max-workers [number]', - description: - 'Specifies the maximum number of workers the worker-pool ' + - 'will spawn for transforming files. This defaults to the number of the ' + - 'cores available on your machine.', - parse: workers => Number(workers), - }, - { - command: '--dev [boolean]', - description: 'If false, skip all dev-only code path', - parse: val => val !== 'false', - default: true, - }, - { - command: '--verbose', - description: 'Enables logging', - default: false, - }, - ], -}; diff --git a/packages/cli/src/commands/index.js b/packages/cli/src/commands/index.js index b35c831fb..fded7f655 100644 --- a/packages/cli/src/commands/index.js +++ b/packages/cli/src/commands/index.js @@ -27,7 +27,6 @@ import uninstall from './install/uninstall'; import upgrade from './upgrade/upgrade'; import logAndroid from './logAndroid/logAndroid'; import logIOS from './logIOS/logIOS'; -import dependencies from './dependencies/dependencies'; import info from './info/info'; /** @@ -49,7 +48,6 @@ const loadLocalCommands: Array = [ upgrade, logAndroid, logIOS, - dependencies, info, ];