Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

Commit 8a5629d

Browse files
authored
Merge pull request #41 from apisearch-io/feature/improved-commands
Improved commands and added query command
2 parents a8ce930 + eea9c0e commit 8a5629d

29 files changed

+5205
-478
lines changed

.circleci/config.yml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,6 @@ jobs:
33
build:
44
docker:
55
- image: circleci/php:7.1-cli
6-
- image: redis:4-alpine
7-
8-
- image: "docker.elastic.co/elasticsearch/elasticsearch:6.2.4"
9-
environment:
10-
cluster.name: apisearch
11-
http.host: 0.0.0.0
12-
transport.host: 0.0.0.0
13-
ES_JAVA_OPTS: "-Xms1g -Xmx1g"
14-
node.max_local_storage_nodes: 10
15-
discovery.type: single-node
16-
17-
- image: "apisearchio/search-server:latest"
18-
environment:
19-
APISEARCH_GOD_TOKEN: 0e4d75ba-c640-44c1-a745-06ee51db4e93
20-
APISEARCH_READONLY_TOKEN: 410806ed-f2c2-8d22-96ea-7fb68026df34
21-
APISEARCH_PING_TOKEN: 6326d504-0a5f-f1ae-7344-8e70b75fcde9
22-
APISEARCH_ENABLED_PLUGINS: redis_storage
23-
ELASTICSEARCH_HOST: localhost
24-
ELASTICSEARCH_PORT: 9200
25-
ELASTICSEARCH_REFRESH_ON_WRITE: 1
26-
REDIS_STORAGE_HOST: localhost
27-
REDIS_STORAGE_PORT: 6379
286

297
working_directory: ~/project
308
steps:
@@ -33,4 +11,4 @@ jobs:
3311
name: Run tests
3412
command: |
3513
composer install -n --prefer-dist --no-suggest
36-
sh .circleci/run-tests
14+
composer test

.circleci/run-tests

Lines changed: 0 additions & 14 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
vendor
2-
composer.lock
3-
composer.lock
42
var

.php_cs.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"7.1.26-1+ubuntu18.04.1+deb.sury.org+1","version":"2.14.0:v2.14.0#b788ea0af899cedc8114dca7db119c93b6685da2","rules":{"blank_line_after_namespace":true,"braces":{"allow_single_line_closure":true},"class_definition":{"single_line":true},"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"class_attributes_separation":{"elements":["method"]},"concat_space":{"spacing":"none"},"declare_equal_normalize":true,"function_typehint_space":true,"include":true,"increment_style":true,"lowercase_cast":true,"lowercase_static_reference":true,"magic_constant_casing":true,"magic_method_casing":true,"native_function_casing":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["curly_brace_block","extra","parenthesis_brace_block","square_brace_block","throw","use"]},"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":{"use":"echo"},"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unneeded_curly_braces":true,"no_unneeded_final_method":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"php_unit_fqcn_annotation":true,"phpdoc_align":{"tags":["method","param","property","return","throws","type","var"]},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_empty_return":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"protected_to_private":true,"return_type_declaration":true,"semicolon_after_instruction":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"ternary_operator_spaces":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true},"hashes":{"Twig\/MethodAccessorExtension.php":2939807874,"Twig\/AggregationTranslationExtension.php":2415810000,"Twig\/UrlBuilderExtension.php":2201893333,"DependencyInjection\/CompilerPass\/ExporterCompilerPass.php":857546720,"DependencyInjection\/CompilerPass\/ReadTransformerCompilerPass.php":3948110591,"DependencyInjection\/CompilerPass\/WriteTransformerCompilerPass.php":2530587380,"DependencyInjection\/CompilerPass\/RepositoryCompilerPass.php":2396654015,"DependencyInjection\/ApisearchExtension.php":112225700,"DependencyInjection\/ApisearchConfiguration.php":3701803641,"ApisearchBundle.php":3640212495,"Translator\/AggregationTranslator.php":4238166597,"Command\/ExportIndexCommand.php":1321012391,"Command\/ImportIndexCommand.php":1581740785,"Command\/PrintTokensCommand.php":276913128,"Command\/DeleteTokensCommand.php":1800041030,"Command\/ApisearchCommand.php":2188021223,"Command\/ConfigureIndexCommand.php":1879894960,"Command\/ApisearchFormattedCommand.php":1573978344,"Command\/PrintIndicesCommand.php":2082971206,"Command\/AddTokenCommand.php":3976278823,"Command\/WithRepositoryBucketCommand.php":3882313592,"Command\/WithAppRepositoryBucketCommand.php":3069075073,"Command\/DeleteTokenCommand.php":3019199442,"Command\/CreateIndexCommand.php":244289546,"Command\/DeleteIndexCommand.php":2512043588,"Command\/ResetIndexCommand.php":2081910409,"Tests\/Functional\/ApisearchBundleFunctionalTest.php":3264653550,"Tests\/Functional\/ProductReadTransformer.php":1666987200,"Tests\/Functional\/DependencyInjection\/DisableCommandsTest.php":2956180423,"Tests\/Functional\/DependencyInjection\/ApisearchConfigurationTest.php":271608124,"Tests\/Functional\/DependencyInjection\/CompilerPass\/InMemoryRepositoryCompilerPassTest.php":3052848166,"Tests\/Functional\/DependencyInjection\/CompilerPass\/TransformersCompilerPassTest.php":1388027657,"Tests\/Functional\/DependencyInjection\/CompilerPass\/HttpRepositoryCompilerPassTest.php":2500445244,"Tests\/Functional\/DependencyInjection\/EnableCommandsTest.php":1149363544,"Tests\/Functional\/ProductBothTransformer.php":3061253314,"Tests\/Functional\/Command\/AddDeleteTokensCommandTest.php":67286622,"Tests\/Functional\/Command\/PrintIndicesCommandTest.php":481741707,"Tests\/Functional\/ProductWriteTransformer.php":4090808924}}
1+
{"php":"7.1.23-2+ubuntu16.04.1+deb.sury.org+1","version":"2.14.0:v2.14.0#b788ea0af899cedc8114dca7db119c93b6685da2","rules":{"blank_line_after_namespace":true,"braces":{"allow_single_line_closure":true},"class_definition":{"single_line":true},"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"class_attributes_separation":{"elements":["method"]},"concat_space":{"spacing":"none"},"declare_equal_normalize":true,"function_typehint_space":true,"include":true,"increment_style":true,"lowercase_cast":true,"lowercase_static_reference":true,"magic_constant_casing":true,"magic_method_casing":true,"native_function_casing":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["curly_brace_block","extra","parenthesis_brace_block","square_brace_block","throw","use"]},"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":{"use":"echo"},"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unneeded_curly_braces":true,"no_unneeded_final_method":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"php_unit_fqcn_annotation":true,"phpdoc_align":{"tags":["method","param","property","return","throws","type","var"]},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_empty_return":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"protected_to_private":true,"return_type_declaration":true,"semicolon_after_instruction":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"ternary_operator_spaces":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true},"hashes":{"Tests\/Functional\/ProductBothTransformer.php":3061253314,"Tests\/Functional\/ProductReadTransformer.php":1666987200,"Tests\/Functional\/ApisearchBundleFunctionalTest.php":1130132530,"Tests\/Functional\/ProductWriteTransformer.php":4090808924,"Tests\/Functional\/Command\/IndexCommandTest.php":673234498,"Tests\/Functional\/Command\/PrintIndicesCommandTest.php":481741707,"Tests\/Functional\/Command\/QueryCommandTest.php":2580406218,"Tests\/Functional\/Command\/AddDeleteTokensCommandTest.php":3415234775,"Tests\/Functional\/DependencyInjection\/EnableCommandsTest.php":1149363544,"Tests\/Functional\/DependencyInjection\/CompilerPass\/InMemoryRepositoryCompilerPassTest.php":3052848166,"Tests\/Functional\/DependencyInjection\/CompilerPass\/TransformersCompilerPassTest.php":1388027657,"Tests\/Functional\/DependencyInjection\/CompilerPass\/HttpRepositoryCompilerPassTest.php":2500445244,"Tests\/Functional\/DependencyInjection\/DisableCommandsTest.php":2956180423,"Tests\/Functional\/DependencyInjection\/ApisearchConfigurationTest.php":271608124,"Translator\/AggregationTranslator.php":4238166597,"ApisearchBundle.php":3640212495,"Twig\/MethodAccessorExtension.php":2939807874,"Twig\/AggregationTranslationExtension.php":2415810000,"Twig\/UrlBuilderExtension.php":2201893333,"Command\/ImportIndexCommand.php":3817139805,"Command\/CreateIndexCommand.php":3585751415,"Command\/ApisearchFormattedCommand.php":1111995920,"Command\/ResetIndexCommand.php":3426927232,"Command\/DeleteIndexCommand.php":1350714493,"Command\/ApisearchCommand.php":332031130,"Command\/WithAppRepositoryBucketCommand.php":2197592132,"Command\/PrintIndicesCommand.php":2224987197,"Command\/DeleteTokensCommand.php":290859330,"Command\/AddTokenCommand.php":3261359949,"Command\/PrintTokensCommand.php":2242601131,"Command\/ExportIndexCommand.php":2541421554,"Command\/ConfigureIndexCommand.php":2627529992,"Command\/WithRepositoryBucketCommand.php":999804449,"Command\/DeleteTokenCommand.php":121828308,"Command\/QueryCommand.php":1694657375,"DependencyInjection\/CompilerPass\/WriteTransformerCompilerPass.php":2530587380,"DependencyInjection\/CompilerPass\/ExporterCompilerPass.php":857546720,"DependencyInjection\/CompilerPass\/RepositoryCompilerPass.php":4244359397,"DependencyInjection\/CompilerPass\/ReadTransformerCompilerPass.php":3948110591,"DependencyInjection\/ApisearchConfiguration.php":1136730770,"DependencyInjection\/ApisearchExtension.php":112225700}}

Command/AddTokenCommand.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
namespace Apisearch\Command;
1717

18-
use Apisearch\Model\AppUUID;
19-
use Apisearch\Model\IndexUUID;
2018
use Apisearch\Model\Token;
2119
use Apisearch\Model\TokenUUID;
2220
use Ramsey\Uuid\Uuid;
@@ -36,7 +34,6 @@ class AddTokenCommand extends WithAppRepositoryBucketCommand
3634
protected function configure()
3735
{
3836
$this
39-
->setName('apisearch:add-token')
4037
->setDescription('Add a token')
4138
->addArgument(
4239
'app-name',
@@ -105,7 +102,7 @@ protected function configure()
105102
*
106103
* @return string
107104
*/
108-
protected function getHeader(): string
105+
protected static function getHeader(): string
109106
{
110107
return 'Add token';
111108
}
@@ -118,7 +115,7 @@ protected function getHeader(): string
118115
*
119116
* @return string
120117
*/
121-
protected function getSuccessMessage(
118+
protected static function getSuccessMessage(
122119
InputInterface $input,
123120
$result
124121
): string {
@@ -138,31 +135,16 @@ protected function getSuccessMessage(
138135
*/
139136
protected function runCommand(InputInterface $input, OutputInterface $output)
140137
{
141-
list($appId, $indices) = $this->getRepositoryAndIndices($input, $output);
142-
$endpoints = $this->getEndpoints($input, $output);
143-
144-
$appName = $input->getArgument('app-name');
145-
$this->printInfoMessage(
146-
$output,
147-
$this->getHeader(),
148-
"App name: <strong>{$appName}</strong>"
149-
);
150-
151-
$this->printInfoMessage(
152-
$output,
153-
$this->getHeader(),
154-
"App UUID: <strong>{$appId}</strong>"
155-
);
138+
list($appUUID, $indices) = $this->getRepositoryAndIndices($input, $output);
139+
$endpoints = $this->getEndpoints($input);
156140

157141
$this
158142
->repositoryBucket->findRepository($input->getArgument('app-name'))
159143
->addToken(
160144
new Token(
161145
TokenUUID::createById($input->getArgument('uuid')),
162-
AppUUID::createById($appId),
163-
array_map(function (string $index) {
164-
return IndexUUID::createById($index);
165-
}, $indices),
146+
$appUUID,
147+
$indices,
166148
$input->getOption('http-referrer'),
167149
$endpoints,
168150
$input->getOption('plugin'),

0 commit comments

Comments
 (0)