diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ca5061e4..722bea0a 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -54,6 +54,7 @@ phutil_register_library_map(array( 'ArcanistCommentStyleXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistCommentStyleXHPASTLinterRule.php', 'ArcanistCommitWorkflow' => 'workflow/ArcanistCommitWorkflow.php', 'ArcanistCompilerLintRenderer' => 'lint/renderer/ArcanistCompilerLintRenderer.php', + 'ArcanistComposerLinter' => 'lint/linter/ArcanistComposerLinter.php', 'ArcanistComprehensiveLintEngine' => 'lint/engine/ArcanistComprehensiveLintEngine.php', 'ArcanistConcatenationOperatorXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistConcatenationOperatorXHPASTLinterRule.php', 'ArcanistConfiguration' => 'configuration/ArcanistConfiguration.php', @@ -337,6 +338,7 @@ phutil_register_library_map(array( 'ArcanistCommentStyleXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistCommitWorkflow' => 'ArcanistWorkflow', 'ArcanistCompilerLintRenderer' => 'ArcanistLintRenderer', + 'ArcanistComposerLinter' => 'ArcanistLinter', 'ArcanistComprehensiveLintEngine' => 'ArcanistLintEngine', 'ArcanistConcatenationOperatorXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistConfiguration' => 'Phobject', diff --git a/src/lint/linter/ArcanistComposerLinter.php b/src/lint/linter/ArcanistComposerLinter.php new file mode 100644 index 00000000..02b7c673 --- /dev/null +++ b/src/lint/linter/ArcanistComposerLinter.php @@ -0,0 +1,55 @@ + pht('Lock file out-of-date'), + ); + } + + public function lintPath($path) { + switch (basename($path)) { + case 'composer.json': + $this->lintComposerJson($path); + break; + case 'composer.lock': + break; + } + } + + private function lintComposerJson($path) { + $composer_hash = md5(Filesystem::readFile(dirname($path).'/composer.json')); + $composer_lock = phutil_json_decode( + Filesystem::readFile(dirname($path).'/composer.lock')); + + if ($composer_hash !== $composer_lock['hash']) { + $this->raiseLintAtPath( + self::LINT_OUT_OF_DATE, + pht( + "The '%s' file seems to be out-of-date. ". + "You probably need to run `%s`.", + 'composer.lock', + 'composer update')); + } + } + +}