jets-fs 1.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.circleci/bin/commit_docs.sh +26 -0
- data/.circleci/config.yml +126 -0
- data/.codebuild/README.md +68 -0
- data/.codebuild/bin/jets +3 -0
- data/.codebuild/buildspec-base.yml +14 -0
- data/.codebuild/integration.sh +72 -0
- data/.codebuild/jets.postman_collection.json +323 -0
- data/.codebuild/scripts/install-docker.sh +12 -0
- data/.codebuild/scripts/install-dynamodb-local.sh +22 -0
- data/.codebuild/scripts/install-java.sh +22 -0
- data/.codebuild/scripts/install-node.sh +4 -0
- data/.github/ISSUE_TEMPLATE.md +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +73 -0
- data/.github/ISSUE_TEMPLATE/documentation.md +27 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +64 -0
- data/.github/ISSUE_TEMPLATE/question.md +16 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +42 -0
- data/.gitignore +24 -0
- data/.gitmodules +6 -0
- data/.python-version +1 -0
- data/.rspec +4 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +533 -0
- data/Dockerfile +16 -0
- data/Dockerfile.base +53 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +190 -0
- data/Guardfile +22 -0
- data/LICENSE.txt +22 -0
- data/Procfile +2 -0
- data/README.md +203 -0
- data/Rakefile +21 -0
- data/backers.md +16 -0
- data/bin/release +9 -0
- data/buildspec.yml +18 -0
- data/exe/jets +14 -0
- data/jets.gemspec +61 -0
- data/lib/jets.rb +71 -0
- data/lib/jets/application.rb +308 -0
- data/lib/jets/aws_info.rb +111 -0
- data/lib/jets/aws_services.rb +60 -0
- data/lib/jets/aws_services/stack_status.rb +59 -0
- data/lib/jets/booter.rb +130 -0
- data/lib/jets/builders.rb +16 -0
- data/lib/jets/builders/code_builder.rb +379 -0
- data/lib/jets/builders/code_size.rb +57 -0
- data/lib/jets/builders/gem_replacer.rb +76 -0
- data/lib/jets/builders/handler_generator.rb +172 -0
- data/lib/jets/builders/lambda_layer.rb +69 -0
- data/lib/jets/builders/md5.rb +60 -0
- data/lib/jets/builders/md5_zip.rb +61 -0
- data/lib/jets/builders/purger.rb +35 -0
- data/lib/jets/builders/rack_packager.rb +51 -0
- data/lib/jets/builders/rackup_wrappers/rackup +19 -0
- data/lib/jets/builders/rackup_wrappers/rackup.rb +7 -0
- data/lib/jets/builders/reconfigure_rails.rb +114 -0
- data/lib/jets/builders/reconfigure_rails/config/initializers/jets.rb +16 -0
- data/lib/jets/builders/ruby_packager.rb +207 -0
- data/lib/jets/builders/shim_vars.rb +5 -0
- data/lib/jets/builders/shim_vars/app.rb +78 -0
- data/lib/jets/builders/shim_vars/base.rb +25 -0
- data/lib/jets/builders/shim_vars/shared.rb +37 -0
- data/lib/jets/builders/templates/handler.rb +12 -0
- data/lib/jets/builders/tidy.rb +107 -0
- data/lib/jets/builders/util.rb +31 -0
- data/lib/jets/camelizer.rb +67 -0
- data/lib/jets/cfn.rb +6 -0
- data/lib/jets/cfn/builders.rb +20 -0
- data/lib/jets/cfn/builders/api_deployment_builder.rb +58 -0
- data/lib/jets/cfn/builders/api_gateway_builder.rb +80 -0
- data/lib/jets/cfn/builders/base_child_builder.rb +82 -0
- data/lib/jets/cfn/builders/controller_builder.rb +42 -0
- data/lib/jets/cfn/builders/function_builder.rb +14 -0
- data/lib/jets/cfn/builders/interface.rb +127 -0
- data/lib/jets/cfn/builders/job_builder.rb +14 -0
- data/lib/jets/cfn/builders/parent_builder.rb +93 -0
- data/lib/jets/cfn/builders/rule_builder.rb +24 -0
- data/lib/jets/cfn/builders/shared_builder.rb +14 -0
- data/lib/jets/cfn/ship.rb +189 -0
- data/lib/jets/cfn/status.rb +212 -0
- data/lib/jets/cfn/upload.rb +139 -0
- data/lib/jets/cli.rb +189 -0
- data/lib/jets/commands.rb +27 -0
- data/lib/jets/commands/base.rb +164 -0
- data/lib/jets/commands/build.rb +217 -0
- data/lib/jets/commands/call.rb +174 -0
- data/lib/jets/commands/call/anonymous_guesser.rb +96 -0
- data/lib/jets/commands/call/autoload_guesser.rb +112 -0
- data/lib/jets/commands/call/base_guesser.rb +33 -0
- data/lib/jets/commands/call/guesser.rb +48 -0
- data/lib/jets/commands/clean.rb +23 -0
- data/lib/jets/commands/clean/base.rb +24 -0
- data/lib/jets/commands/clean/build.rb +13 -0
- data/lib/jets/commands/clean/log.rb +107 -0
- data/lib/jets/commands/console.rb +13 -0
- data/lib/jets/commands/db.rb +15 -0
- data/lib/jets/commands/db/environment-task.rake +3 -0
- data/lib/jets/commands/db/tasks.rb +44 -0
- data/lib/jets/commands/dbconsole.rb +131 -0
- data/lib/jets/commands/delete.rb +143 -0
- data/lib/jets/commands/deploy.rb +131 -0
- data/lib/jets/commands/dynamodb.rb +22 -0
- data/lib/jets/commands/dynamodb/migrate.rb +9 -0
- data/lib/jets/commands/dynamodb/migrator.rb +36 -0
- data/lib/jets/commands/gems.rb +21 -0
- data/lib/jets/commands/help.rb +9 -0
- data/lib/jets/commands/help/build.md +6 -0
- data/lib/jets/commands/help/call.md +61 -0
- data/lib/jets/commands/help/clean/build.md +5 -0
- data/lib/jets/commands/help/clean/log.md +5 -0
- data/lib/jets/commands/help/console.md +18 -0
- data/lib/jets/commands/help/db/generate.md +8 -0
- data/lib/jets/commands/help/dbconsole.md +9 -0
- data/lib/jets/commands/help/delete.md +22 -0
- data/lib/jets/commands/help/deploy.md +32 -0
- data/lib/jets/commands/help/dynamodb/generate.md +52 -0
- data/lib/jets/commands/help/dynamodb/migrate.md +4 -0
- data/lib/jets/commands/help/gems/check.md +8 -0
- data/lib/jets/commands/help/generate.md +22 -0
- data/lib/jets/commands/help/import/rack.md +13 -0
- data/lib/jets/commands/help/import/rails.md +11 -0
- data/lib/jets/commands/help/new.md +42 -0
- data/lib/jets/commands/help/routes.md +16 -0
- data/lib/jets/commands/help/runner.md +17 -0
- data/lib/jets/commands/help/server.md +15 -0
- data/lib/jets/commands/help/status.md +14 -0
- data/lib/jets/commands/help/upgrade.md +5 -0
- data/lib/jets/commands/help/url.md +6 -0
- data/lib/jets/commands/import.rb +18 -0
- data/lib/jets/commands/import/base.rb +49 -0
- data/lib/jets/commands/import/cheatsheet.rb +35 -0
- data/lib/jets/commands/import/rack.rb +16 -0
- data/lib/jets/commands/import/rail.rb +74 -0
- data/lib/jets/commands/import/sequence.rb +90 -0
- data/lib/jets/commands/import/templates/config/database.yml +26 -0
- data/lib/jets/commands/import/templates/submodules-cheatsheet.md +89 -0
- data/lib/jets/commands/main.rb +152 -0
- data/lib/jets/commands/markdown.rb +8 -0
- data/lib/jets/commands/markdown/creator.rb +58 -0
- data/lib/jets/commands/markdown/index.rb +27 -0
- data/lib/jets/commands/markdown/page.rb +125 -0
- data/lib/jets/commands/markdown/shell.rb +11 -0
- data/lib/jets/commands/new.rb +157 -0
- data/lib/jets/commands/rake_command.rb +61 -0
- data/lib/jets/commands/rake_tasks.rb +45 -0
- data/lib/jets/commands/runner.rb +18 -0
- data/lib/jets/commands/sequence.rb +99 -0
- data/lib/jets/commands/stack_info.rb +30 -0
- data/lib/jets/commands/templates/skeleton/.gitignore +12 -0
- data/lib/jets/commands/templates/skeleton/.jetskeep +1 -0
- data/lib/jets/commands/templates/skeleton/.rspec +3 -0
- data/lib/jets/commands/templates/skeleton/Gemfile.tt +35 -0
- data/lib/jets/commands/templates/skeleton/Procfile +7 -0
- data/lib/jets/commands/templates/skeleton/README.md +11 -0
- data/lib/jets/commands/templates/skeleton/Rakefile +2 -0
- data/lib/jets/commands/templates/skeleton/app/controllers/application_controller.rb +2 -0
- data/lib/jets/commands/templates/skeleton/app/helpers/application_helper.rb +2 -0
- data/lib/jets/commands/templates/skeleton/app/jobs/application_job.rb +4 -0
- data/lib/jets/commands/templates/skeleton/app/models/application_item.rb +2 -0
- data/lib/jets/commands/templates/skeleton/app/models/application_record.rb +3 -0
- data/lib/jets/commands/templates/skeleton/app/views/layouts/application.html.erb.tt +25 -0
- data/lib/jets/commands/templates/skeleton/config.ru +5 -0
- data/lib/jets/commands/templates/skeleton/config/application.rb.tt +66 -0
- data/lib/jets/commands/templates/skeleton/config/database.yml.tt +26 -0
- data/lib/jets/commands/templates/skeleton/config/dynamodb.yml +22 -0
- data/lib/jets/commands/templates/skeleton/config/environments/development.rb +4 -0
- data/lib/jets/commands/templates/skeleton/config/environments/production.rb +4 -0
- data/lib/jets/commands/templates/skeleton/config/routes.rb +9 -0
- data/lib/jets/commands/templates/skeleton/db/.gitkeep +0 -0
- data/lib/jets/commands/templates/skeleton/public/404.html +67 -0
- data/lib/jets/commands/templates/skeleton/public/422.html +67 -0
- data/lib/jets/commands/templates/skeleton/public/500.html +66 -0
- data/lib/jets/commands/templates/skeleton/public/favicon.ico +0 -0
- data/lib/jets/commands/templates/skeleton/public/index.html.tt +91 -0
- data/lib/jets/commands/templates/skeleton/spec/controllers/posts_controller_spec.rb +15 -0
- data/lib/jets/commands/templates/skeleton/spec/fixtures/payloads/posts-index.json +51 -0
- data/lib/jets/commands/templates/skeleton/spec/fixtures/payloads/posts-show.json +53 -0
- data/lib/jets/commands/templates/skeleton/spec/spec_helper.rb.tt +30 -0
- data/lib/jets/commands/templates/webpacker/app/javascript/packs/application.js.tt +14 -0
- data/lib/jets/commands/templates/webpacker/app/javascript/packs/theme.scss.tt +24 -0
- data/lib/jets/commands/templates/webpacker/app/javascript/src/jets/crud.js +87 -0
- data/lib/jets/commands/upgrade.rb +146 -0
- data/lib/jets/commands/upgrade/templates/bin/webpack +19 -0
- data/lib/jets/commands/upgrade/templates/bin/webpack-dev-server +19 -0
- data/lib/jets/commands/url.rb +68 -0
- data/lib/jets/commands/webpacker_template.rb +18 -0
- data/lib/jets/controller.rb +16 -0
- data/lib/jets/controller/base.rb +103 -0
- data/lib/jets/controller/callbacks.rb +62 -0
- data/lib/jets/controller/cookies.rb +40 -0
- data/lib/jets/controller/cookies/jar.rb +269 -0
- data/lib/jets/controller/layout.rb +17 -0
- data/lib/jets/controller/middleware.rb +5 -0
- data/lib/jets/controller/middleware/cors.rb +60 -0
- data/lib/jets/controller/middleware/local.rb +119 -0
- data/lib/jets/controller/middleware/local/api_gateway.rb +93 -0
- data/lib/jets/controller/middleware/local/mimic_aws_call.rb +38 -0
- data/lib/jets/controller/middleware/local/route_matcher.rb +97 -0
- data/lib/jets/controller/middleware/main.rb +46 -0
- data/lib/jets/controller/middleware/webpacker_setup.rb +6 -0
- data/lib/jets/controller/params.rb +87 -0
- data/lib/jets/controller/rack.rb +5 -0
- data/lib/jets/controller/rack/adapter.rb +63 -0
- data/lib/jets/controller/rack/env.rb +105 -0
- data/lib/jets/controller/redirection.rb +55 -0
- data/lib/jets/controller/rendering.rb +84 -0
- data/lib/jets/controller/rendering/rack_renderer.rb +238 -0
- data/lib/jets/controller/request.rb +29 -0
- data/lib/jets/controller/response.rb +61 -0
- data/lib/jets/core.rb +211 -0
- data/lib/jets/core_ext/kernel.rb +56 -0
- data/lib/jets/db.rb +15 -0
- data/lib/jets/dotenv.rb +39 -0
- data/lib/jets/erb.rb +51 -0
- data/lib/jets/generator.rb +41 -0
- data/lib/jets/generator/templates/erb/controller/view.html.erb +2 -0
- data/lib/jets/generator/templates/erb/scaffold/_form.html.erb +39 -0
- data/lib/jets/generator/templates/erb/scaffold/edit.html.erb +6 -0
- data/lib/jets/generator/templates/erb/scaffold/index.html.erb +29 -0
- data/lib/jets/generator/templates/erb/scaffold/new.html.erb +5 -0
- data/lib/jets/generator/templates/erb/scaffold/show.html.erb +9 -0
- data/lib/jets/generator/templates/rails/assets/javascript.js +2 -0
- data/lib/jets/generator/templates/rails/assets/stylesheet.css +4 -0
- data/lib/jets/generator/templates/rails/controller/controller.rb +13 -0
- data/lib/jets/generator/templates/rails/helper/helper.rb +4 -0
- data/lib/jets/generator/templates/rails/scaffold/scaffold.css +80 -0
- data/lib/jets/generator/templates/rails/scaffold_controller/api_controller.rb +62 -0
- data/lib/jets/generator/templates/rails/scaffold_controller/controller.rb +79 -0
- data/lib/jets/inflections.rb +32 -0
- data/lib/jets/internal/app/controllers/jets/public_controller.rb +31 -0
- data/lib/jets/internal/app/controllers/jets/rack_controller.rb +25 -0
- data/lib/jets/internal/app/functions/jets/base_path.rb +153 -0
- data/lib/jets/internal/app/jobs/jets/preheat_job.rb +62 -0
- data/lib/jets/io.rb +14 -0
- data/lib/jets/job.rb +4 -0
- data/lib/jets/job/base.rb +29 -0
- data/lib/jets/job/dsl.rb +108 -0
- data/lib/jets/klass.rb +109 -0
- data/lib/jets/lambda.rb +18 -0
- data/lib/jets/lambda/dsl.rb +384 -0
- data/lib/jets/lambda/function.rb +29 -0
- data/lib/jets/lambda/function_constructor.rb +55 -0
- data/lib/jets/lambda/functions.rb +34 -0
- data/lib/jets/lambda/task.rb +111 -0
- data/lib/jets/logger.rb +24 -0
- data/lib/jets/mega.rb +7 -0
- data/lib/jets/mega/hash_converter.rb +25 -0
- data/lib/jets/mega/request.rb +140 -0
- data/lib/jets/mega/request/source.rb +21 -0
- data/lib/jets/middleware.rb +38 -0
- data/lib/jets/middleware/configurator.rb +84 -0
- data/lib/jets/middleware/default_stack.rb +49 -0
- data/lib/jets/middleware/layer.rb +34 -0
- data/lib/jets/middleware/stack.rb +77 -0
- data/lib/jets/naming.rb +49 -0
- data/lib/jets/overrides/lambda.rb +1 -0
- data/lib/jets/overrides/lambda/marshaller.rb +31 -0
- data/lib/jets/overrides/rails.rb +4 -0
- data/lib/jets/overrides/rails/asset_tag_helper.rb +114 -0
- data/lib/jets/overrides/rails/common_methods.rb +20 -0
- data/lib/jets/overrides/rails/rendering_helper.rb +26 -0
- data/lib/jets/overrides/rails/url_helper.rb +25 -0
- data/lib/jets/poly_fun.rb +82 -0
- data/lib/jets/poly_fun/base_executor.rb +125 -0
- data/lib/jets/poly_fun/lambda_executor.rb +16 -0
- data/lib/jets/poly_fun/node_error.rb +8 -0
- data/lib/jets/poly_fun/node_executor.rb +54 -0
- data/lib/jets/poly_fun/python_error.rb +8 -0
- data/lib/jets/poly_fun/python_executor.rb +23 -0
- data/lib/jets/preheat.rb +117 -0
- data/lib/jets/processors.rb +4 -0
- data/lib/jets/processors/deducer.rb +65 -0
- data/lib/jets/processors/main_processor.rb +59 -0
- data/lib/jets/rack_server.rb +80 -0
- data/lib/jets/rdoc.rb +30 -0
- data/lib/jets/resource.rb +74 -0
- data/lib/jets/resource/api_gateway.rb +9 -0
- data/lib/jets/resource/api_gateway/base_path.rb +5 -0
- data/lib/jets/resource/api_gateway/base_path/function.rb +42 -0
- data/lib/jets/resource/api_gateway/base_path/mapping.rb +44 -0
- data/lib/jets/resource/api_gateway/base_path/role.rb +76 -0
- data/lib/jets/resource/api_gateway/cors.rb +61 -0
- data/lib/jets/resource/api_gateway/deployment.rb +78 -0
- data/lib/jets/resource/api_gateway/domain_name.rb +59 -0
- data/lib/jets/resource/api_gateway/method.rb +98 -0
- data/lib/jets/resource/api_gateway/resource.rb +78 -0
- data/lib/jets/resource/api_gateway/rest_api.rb +60 -0
- data/lib/jets/resource/api_gateway/rest_api/change_detection.rb +42 -0
- data/lib/jets/resource/api_gateway/rest_api/logical_id.rb +63 -0
- data/lib/jets/resource/api_gateway/rest_api/routes.rb +11 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change.rb +12 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change/base.rb +130 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change/to.rb +29 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb +39 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/collision.rb +123 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/collision/variable_exception.rb +7 -0
- data/lib/jets/resource/associated.rb +26 -0
- data/lib/jets/resource/base.rb +28 -0
- data/lib/jets/resource/child_stack.rb +7 -0
- data/lib/jets/resource/child_stack/api_deployment.rb +56 -0
- data/lib/jets/resource/child_stack/api_gateway.rb +29 -0
- data/lib/jets/resource/child_stack/app_class.rb +112 -0
- data/lib/jets/resource/child_stack/base.rb +24 -0
- data/lib/jets/resource/child_stack/shared.rb +90 -0
- data/lib/jets/resource/config.rb +4 -0
- data/lib/jets/resource/config/config_rule.rb +74 -0
- data/lib/jets/resource/config/managed_rule.rb +15 -0
- data/lib/jets/resource/events.rb +3 -0
- data/lib/jets/resource/events/rule.rb +31 -0
- data/lib/jets/resource/iam.rb +8 -0
- data/lib/jets/resource/iam/application_role.rb +27 -0
- data/lib/jets/resource/iam/base_role_definition.rb +47 -0
- data/lib/jets/resource/iam/class_role.rb +74 -0
- data/lib/jets/resource/iam/function_role.rb +54 -0
- data/lib/jets/resource/iam/managed_policy.rb +22 -0
- data/lib/jets/resource/iam/policy_document.rb +41 -0
- data/lib/jets/resource/lambda.rb +5 -0
- data/lib/jets/resource/lambda/function.rb +216 -0
- data/lib/jets/resource/lambda/function/environment.rb +61 -0
- data/lib/jets/resource/lambda/gem_layer.rb +17 -0
- data/lib/jets/resource/lambda/layer_version.rb +44 -0
- data/lib/jets/resource/permission.rb +45 -0
- data/lib/jets/resource/replacer.rb +77 -0
- data/lib/jets/resource/route53.rb +3 -0
- data/lib/jets/resource/route53/record_set.rb +70 -0
- data/lib/jets/resource/s3.rb +17 -0
- data/lib/jets/resource/sns.rb +3 -0
- data/lib/jets/resource/sqs.rb +3 -0
- data/lib/jets/resource/standardizer.rb +42 -0
- data/lib/jets/route.rb +166 -0
- data/lib/jets/router.rb +175 -0
- data/lib/jets/router/scope.rb +30 -0
- data/lib/jets/rule.rb +4 -0
- data/lib/jets/rule/base.rb +19 -0
- data/lib/jets/rule/dsl.rb +110 -0
- data/lib/jets/spec_helpers.rb +52 -0
- data/lib/jets/spec_helpers/params.rb +10 -0
- data/lib/jets/spec_helpers/request.rb +98 -0
- data/lib/jets/spec_helpers/response.rb +5 -0
- data/lib/jets/stack.rb +103 -0
- data/lib/jets/stack/builder.rb +38 -0
- data/lib/jets/stack/definition.rb +50 -0
- data/lib/jets/stack/function.rb +60 -0
- data/lib/jets/stack/main.rb +5 -0
- data/lib/jets/stack/main/dsl.rb +33 -0
- data/lib/jets/stack/main/extensions/base.rb +45 -0
- data/lib/jets/stack/main/extensions/cloudwatch.rb +19 -0
- data/lib/jets/stack/main/extensions/lambda.rb +71 -0
- data/lib/jets/stack/main/extensions/sns.rb +12 -0
- data/lib/jets/stack/main/extensions/sqs.rb +36 -0
- data/lib/jets/stack/output.rb +38 -0
- data/lib/jets/stack/output/dsl.rb +19 -0
- data/lib/jets/stack/output/lookup.rb +36 -0
- data/lib/jets/stack/parameter.rb +38 -0
- data/lib/jets/stack/parameter/dsl.rb +42 -0
- data/lib/jets/stack/resource.rb +32 -0
- data/lib/jets/stack/resource/dsl.rb +19 -0
- data/lib/jets/tmp_loader.rb +52 -0
- data/lib/jets/turbine.rb +30 -0
- data/lib/jets/turbo.rb +47 -0
- data/lib/jets/turbo/database_yaml.rb +41 -0
- data/lib/jets/turbo/project/.gitignore +12 -0
- data/lib/jets/turbo/project/.jetskeep +1 -0
- data/lib/jets/turbo/project/Gemfile +16 -0
- data/lib/jets/turbo/project/Rakefile +2 -0
- data/lib/jets/turbo/project/app/controllers/application_controller.rb +2 -0
- data/lib/jets/turbo/project/app/helpers/application_helper.rb +2 -0
- data/lib/jets/turbo/project/app/jobs/application_job.rb +4 -0
- data/lib/jets/turbo/project/config.ru +5 -0
- data/lib/jets/turbo/project/config/application.rb +4 -0
- data/lib/jets/turbo/project/config/routes.rb +4 -0
- data/lib/jets/turbo/rail.rb +113 -0
- data/lib/jets/turbo/templates/config/database.yml +26 -0
- data/lib/jets/util.rb +38 -0
- data/lib/jets/version.rb +3 -0
- data/readme/prerelease.md +6 -0
- data/readme/testing.md +60 -0
- metadata +859 -0
data/lib/jets/cli.rb
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
require "thor"
|
|
2
|
+
|
|
3
|
+
class Jets::CLI
|
|
4
|
+
def self.start(given_args=ARGV)
|
|
5
|
+
new(given_args).start
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.thor_tasks
|
|
9
|
+
Jets::Commands::Base.namespaced_commands
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize(given_args=ARGV, **config)
|
|
13
|
+
@given_args = given_args.dup
|
|
14
|
+
@config = config
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def start
|
|
18
|
+
command_class = lookup(full_command)
|
|
19
|
+
if command_class
|
|
20
|
+
boot_jets
|
|
21
|
+
command_class.perform(full_command, thor_args)
|
|
22
|
+
elsif version_requested?
|
|
23
|
+
puts Jets.version
|
|
24
|
+
else
|
|
25
|
+
main_help
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def version_requested?
|
|
30
|
+
# jets --version
|
|
31
|
+
# jets -v
|
|
32
|
+
version_flags = ["--version", "-v"]
|
|
33
|
+
@given_args.length == 1 && !(@given_args & version_flags).empty?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# The commands new and help do not call Jets.boot. Main reason is that
|
|
37
|
+
# Jets.boot are ran inside a Jets project folder.
|
|
38
|
+
#
|
|
39
|
+
# * jets new - need to generate a project outside a project folder.
|
|
40
|
+
# * jets help - don't need to be in a project folder general help.
|
|
41
|
+
# When you are inside a project folder though, more help commands
|
|
42
|
+
# are available and displayed.
|
|
43
|
+
#
|
|
44
|
+
def boot_jets
|
|
45
|
+
command = thor_args.first
|
|
46
|
+
if !%w[new help].include?(command)
|
|
47
|
+
set_jets_env_from_cli_arg!
|
|
48
|
+
Jets.boot
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Adjust JETS_ENV before boot_jets is called for the jets deploy
|
|
53
|
+
# command. Must do this early in the process before Jets.boot because
|
|
54
|
+
# Jets.boot calls Jets.env as part of the bootup process in
|
|
55
|
+
# require_bundle_gems and sets the Jets.env to whatever the JETS_ENV is
|
|
56
|
+
# at the time.
|
|
57
|
+
#
|
|
58
|
+
# Defaults to development when not set.
|
|
59
|
+
def set_jets_env_from_cli_arg!
|
|
60
|
+
command, env = thor_args[0..1]
|
|
61
|
+
return unless %w[deploy delete].include?(command)
|
|
62
|
+
env = nil if env&.starts_with?('-')
|
|
63
|
+
return unless env
|
|
64
|
+
ENV['JETS_ENV'] = env ? env : 'development'
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# thor_args normalized the args Array to work with our Thor command
|
|
68
|
+
# subclasses.
|
|
69
|
+
# 1. The namespace is stripe
|
|
70
|
+
# 2. Help is shifted in front if a help flag is detected
|
|
71
|
+
def thor_args
|
|
72
|
+
args = @given_args.clone
|
|
73
|
+
|
|
74
|
+
help_args = args & help_flags
|
|
75
|
+
unless help_args.empty?
|
|
76
|
+
# Allow using help flags at the end of the command to trigger help menu
|
|
77
|
+
args -= help_flags # remove "help" and help flags from args
|
|
78
|
+
args[0] = meth # first command will always be the meth now since
|
|
79
|
+
# we removed the help flags
|
|
80
|
+
args.unshift("help")
|
|
81
|
+
args.compact!
|
|
82
|
+
return args
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# reassigns the command without the namespace if reached here
|
|
86
|
+
args[0] = meth
|
|
87
|
+
args.compact
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
ALIASES = {
|
|
91
|
+
"g" => "generate",
|
|
92
|
+
"c" => "console",
|
|
93
|
+
"s" => "server",
|
|
94
|
+
"db" => "dbconsole",
|
|
95
|
+
}
|
|
96
|
+
def full_command
|
|
97
|
+
# Removes any args that starts with -, those are option args.
|
|
98
|
+
# Also remove "help" flag.
|
|
99
|
+
args = @given_args.reject {|o| o =~ /^-/ } - help_flags
|
|
100
|
+
command = args[0] # first argument should always be the command
|
|
101
|
+
command = ALIASES[command] || command
|
|
102
|
+
Jets::Commands::Base.autocomplete(command)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# 1. look up Thor tasks
|
|
106
|
+
# 2. look up Rake tasks
|
|
107
|
+
# 3. help menu with all commands when both Thor and Rake tasks are not found
|
|
108
|
+
def lookup(full_command)
|
|
109
|
+
thor_task_found = Jets::Commands::Base.namespaced_commands.include?(full_command)
|
|
110
|
+
if thor_task_found
|
|
111
|
+
return Jets::Commands::Base.klass_from_namespace(namespace)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
rake_task_found = Jets::Commands::RakeCommand.namespaced_commands.include?(full_command)
|
|
115
|
+
if rake_task_found
|
|
116
|
+
return Jets::Commands::RakeCommand
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# ["-h", "-?", "--help", "-D", "help"]
|
|
121
|
+
def help_flags
|
|
122
|
+
Thor::HELP_MAPPINGS + ["help"]
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def namespace
|
|
126
|
+
return nil unless full_command
|
|
127
|
+
|
|
128
|
+
if full_command.include?(':')
|
|
129
|
+
words = full_command.split(':')
|
|
130
|
+
words.pop
|
|
131
|
+
words.join(':')
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def meth
|
|
136
|
+
return nil unless full_command
|
|
137
|
+
|
|
138
|
+
if full_command.include?(':')
|
|
139
|
+
full_command.split(':').pop
|
|
140
|
+
else
|
|
141
|
+
full_command
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def main_help
|
|
146
|
+
shell = Thor::Shell::Basic.new
|
|
147
|
+
shell.say "Commands:"
|
|
148
|
+
shell.print_table(thor_list, :indent => 2, :truncate => true)
|
|
149
|
+
|
|
150
|
+
unless rake_list.empty?
|
|
151
|
+
shell.say "\nCommands via rake:"
|
|
152
|
+
shell.print_table(rake_list, :indent => 2, :truncate => true)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
shell.say "\n"
|
|
156
|
+
shell.say main_help_body
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def thor_list
|
|
160
|
+
Jets::Commands::Base.help_list(show_all_tasks)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def rake_list
|
|
164
|
+
list = Jets::Commands::RakeCommand.formatted_rake_tasks(show_all_tasks)
|
|
165
|
+
list.map do |array|
|
|
166
|
+
array[0] = "jets #{array[0]}"
|
|
167
|
+
array
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def show_all_tasks
|
|
172
|
+
@given_args.include?("--all") || @given_args.include?("-A")
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def main_help_body
|
|
176
|
+
<<-EOL
|
|
177
|
+
Add -h to any of the commands for more help. Examples:
|
|
178
|
+
|
|
179
|
+
jets call -h
|
|
180
|
+
jets routes -h
|
|
181
|
+
jets deploy -h
|
|
182
|
+
jets status -h
|
|
183
|
+
jets dynamodb:create -h
|
|
184
|
+
jets db:create -h
|
|
185
|
+
|
|
186
|
+
EOL
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Jets::Commands
|
|
2
|
+
autoload :Base, "jets/commands/base"
|
|
3
|
+
autoload :Build, "jets/commands/build"
|
|
4
|
+
autoload :Call, "jets/commands/call"
|
|
5
|
+
autoload :Clean, "jets/commands/clean"
|
|
6
|
+
autoload :Console, "jets/commands/console"
|
|
7
|
+
autoload :Db, "jets/commands/db"
|
|
8
|
+
autoload :Dbconsole, "jets/commands/dbconsole"
|
|
9
|
+
autoload :Delete, "jets/commands/delete"
|
|
10
|
+
autoload :Deploy, "jets/commands/deploy"
|
|
11
|
+
autoload :Dynamodb, "jets/commands/dynamodb"
|
|
12
|
+
autoload :Gems, 'jets/commands/gems'
|
|
13
|
+
autoload :Help, "jets/commands/help"
|
|
14
|
+
autoload :Import, "jets/commands/import"
|
|
15
|
+
autoload :Main, "jets/commands/main"
|
|
16
|
+
autoload :Markdown, "jets/commands/markdown"
|
|
17
|
+
autoload :New, "jets/commands/new"
|
|
18
|
+
autoload :Process, "jets/commands/process"
|
|
19
|
+
autoload :RakeCommand, "jets/commands/rake_command"
|
|
20
|
+
autoload :RakeTasks, 'jets/commands/rake_tasks'
|
|
21
|
+
autoload :Runner, 'jets/commands/runner'
|
|
22
|
+
autoload :Sequence, "jets/commands/sequence"
|
|
23
|
+
autoload :StackInfo, "jets/commands/stack_info"
|
|
24
|
+
autoload :Upgrade, "jets/commands/upgrade"
|
|
25
|
+
autoload :Url, "jets/commands/url"
|
|
26
|
+
autoload :WebpackerTemplate, 'jets/commands/webpacker_template'
|
|
27
|
+
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
require "thor"
|
|
2
|
+
|
|
3
|
+
# Override thor's long_desc identation behavior
|
|
4
|
+
# https://github.com/erikhuda/thor/issues/398
|
|
5
|
+
class Thor
|
|
6
|
+
module Shell
|
|
7
|
+
class Basic
|
|
8
|
+
def print_wrapped(message, options = {})
|
|
9
|
+
message = "\n#{message}" unless message.starts_with?("\n")
|
|
10
|
+
stdout.puts message
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Jets::Commands::Base < Thor
|
|
17
|
+
class << self
|
|
18
|
+
extend Memoist
|
|
19
|
+
|
|
20
|
+
# thor_args is an array of commands. Examples:
|
|
21
|
+
# ["help"]
|
|
22
|
+
# ["dynamodb:migrate"]
|
|
23
|
+
#
|
|
24
|
+
# Same signature as RakeCommand.perform. Not using full_command.
|
|
25
|
+
def perform(full_command, thor_args)
|
|
26
|
+
config = {} # doesnt seem like config is used
|
|
27
|
+
dispatch(nil, thor_args, nil, config)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Hacky way to handle error for 'jets new' when no project name is passed in to avoid
|
|
31
|
+
# this error:
|
|
32
|
+
#
|
|
33
|
+
# required arguments 'project_name' (Thor::RequiredArgumentMissingError)
|
|
34
|
+
def dispatch(command, given_args, given_opts, config)
|
|
35
|
+
if given_args.reject{|s| s =~ /^-/} == ['new'] # user forgot to pass a project name
|
|
36
|
+
given_args = ['help', 'new']
|
|
37
|
+
end
|
|
38
|
+
super
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Track all command subclasses.
|
|
42
|
+
def subclasses
|
|
43
|
+
@subclasses ||= []
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def inherited(base)
|
|
47
|
+
super
|
|
48
|
+
|
|
49
|
+
if base.name
|
|
50
|
+
self.subclasses << base
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Useful for help menu when we need to have all the definitions loaded.
|
|
55
|
+
# Using constantize instead of require so we dont care about
|
|
56
|
+
# order. The eager load actually uses autoloading.
|
|
57
|
+
def eager_load!
|
|
58
|
+
base_path = File.expand_path("../../", __FILE__)
|
|
59
|
+
Dir.glob("#{base_path}/commands/**/*.rb").select do |path|
|
|
60
|
+
next if !File.file?(path) or path =~ /templates/ or path =~ %r{/markdown/}
|
|
61
|
+
|
|
62
|
+
class_name = path
|
|
63
|
+
.sub(/\.rb$/,'')
|
|
64
|
+
.sub(%r{.*/jets/commands}, 'jets/commands')
|
|
65
|
+
.classify
|
|
66
|
+
class_name = special_class_map(class_name)
|
|
67
|
+
# NOTE: Weird thing where Jets::Commands::Db::Task => Thor::Command
|
|
68
|
+
# because Task is a class available to Thor I believe.
|
|
69
|
+
# puts "eager_load! loading path: #{path} class_name: #{class_name}" if ENV['JETS_DEBUG']
|
|
70
|
+
class_name.constantize # dont have to worry about order.
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
memoize :eager_load!
|
|
74
|
+
|
|
75
|
+
# Fully qualifed task names. Examples:
|
|
76
|
+
# build
|
|
77
|
+
# process:controller
|
|
78
|
+
# dynamodb:migrate:down
|
|
79
|
+
def namespaced_commands
|
|
80
|
+
eager_load!
|
|
81
|
+
subclasses.map do |klass|
|
|
82
|
+
# This all_tasks is part of Thor not the lambda/dsl.rb
|
|
83
|
+
klass.all_tasks.keys.map do |task_name|
|
|
84
|
+
klass = klass.to_s.sub('Jets::Commands::','')
|
|
85
|
+
namespace = klass =~ /^Main/ ? nil : klass.underscore.gsub('/',':')
|
|
86
|
+
[namespace, task_name].compact.join(':')
|
|
87
|
+
end
|
|
88
|
+
end.flatten.sort
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Use Jets banner instead of Thor to account for namespaces in commands.
|
|
92
|
+
def banner(command, namespace = nil, subcommand = false)
|
|
93
|
+
namespace = namespace_from_class(self)
|
|
94
|
+
command_name = command.usage # set with desc when defining tht Thor class
|
|
95
|
+
namespaced_command = [namespace, command_name].compact.join(':')
|
|
96
|
+
|
|
97
|
+
"jets #{namespaced_command}"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def namespace_from_class(klass)
|
|
101
|
+
namespace = klass.to_s.sub('Jets::Commands::', '').underscore.gsub('/',':')
|
|
102
|
+
namespace unless namespace == "main"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def help_list(all=false)
|
|
106
|
+
# hack to show hidden comands when requested
|
|
107
|
+
Thor::HiddenCommand.class_eval do
|
|
108
|
+
def hidden?; false; end
|
|
109
|
+
end if all
|
|
110
|
+
|
|
111
|
+
list = []
|
|
112
|
+
eager_load!
|
|
113
|
+
subclasses.each do |klass|
|
|
114
|
+
commands = klass.printable_commands(true, false)
|
|
115
|
+
commands.reject! { |array| array[0].include?(':help') }
|
|
116
|
+
list += commands
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
list.sort_by! { |array| array[0] }
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def klass_from_namespace(namespace)
|
|
123
|
+
if namespace.nil?
|
|
124
|
+
Jets::Commands::Main
|
|
125
|
+
else
|
|
126
|
+
class_name = namespace.gsub(':','/')
|
|
127
|
+
class_name = "Jets::Commands::#{class_name.classify}"
|
|
128
|
+
class_name = special_class_map(class_name)
|
|
129
|
+
class_name.constantize
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def special_class_map(class_name)
|
|
134
|
+
map = {
|
|
135
|
+
'Jets::Commands::RakeTask' => 'Jets::Commands::RakeTasks',
|
|
136
|
+
'Jets::Commands::Gem' => 'Jets::Commands::Gems',
|
|
137
|
+
}
|
|
138
|
+
map[class_name] || class_name
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# If this fails to find a match then return the original full command
|
|
142
|
+
def autocomplete(full_command)
|
|
143
|
+
return nil if full_command.nil? # jets help
|
|
144
|
+
|
|
145
|
+
eager_load!
|
|
146
|
+
|
|
147
|
+
words = full_command.split(':')
|
|
148
|
+
namespace = words[0..-2].join(':') if words.size > 1
|
|
149
|
+
command = words.last
|
|
150
|
+
|
|
151
|
+
# Thor's normalize_command_name autocompletes the command but then we need to add the namespace back
|
|
152
|
+
begin
|
|
153
|
+
thor_subclass = klass_from_namespace(namespace) # could NameError
|
|
154
|
+
command = thor_subclass.normalize_command_name(command) # could Thor::AmbiguousCommandError
|
|
155
|
+
[namespace, command].compact.join(':')
|
|
156
|
+
rescue NameError
|
|
157
|
+
full_command # return original full_command
|
|
158
|
+
rescue Thor::AmbiguousCommandError => e
|
|
159
|
+
puts "Unable to autodetect the command name. #{e.message}."
|
|
160
|
+
full_command # return original full_command
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
require 'digest'
|
|
2
|
+
|
|
3
|
+
module Jets::Commands
|
|
4
|
+
class Build
|
|
5
|
+
include StackInfo
|
|
6
|
+
|
|
7
|
+
def initialize(options)
|
|
8
|
+
@options = options.dup
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def run
|
|
12
|
+
puts "Building project for Lambda..."
|
|
13
|
+
|
|
14
|
+
return if @options[:noop]
|
|
15
|
+
# run gets called from the CLI and does not have all the stack_options yet.
|
|
16
|
+
# We compute it and change the options early here.
|
|
17
|
+
@options.merge!(stack_type: stack_type, s3_bucket: s3_bucket)
|
|
18
|
+
build
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def build
|
|
22
|
+
build_code unless @options[:templates]
|
|
23
|
+
build_templates
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def build_code
|
|
27
|
+
Jets::Builders::CodeBuilder.new.build unless @options[:noop]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def build_templates
|
|
31
|
+
puts "Building CloudFormation templates."
|
|
32
|
+
clean_templates
|
|
33
|
+
build_minimal_template
|
|
34
|
+
build_all_templates if full?
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def full?
|
|
38
|
+
@options[:templates] || @options[:stack_type] == :full
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def build_all_templates
|
|
42
|
+
# CloudFormation templates
|
|
43
|
+
# 1. Shared templates - child templates needs them
|
|
44
|
+
build_api_gateway_templates
|
|
45
|
+
# 2. Child templates - parent template needs them
|
|
46
|
+
build_app_child_templates
|
|
47
|
+
# 2. Child templates - parent template needs them
|
|
48
|
+
build_shared_resources_templates
|
|
49
|
+
# 4. Finally parent template
|
|
50
|
+
build_parent_template # must be called at the end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def build_minimal_template
|
|
54
|
+
Jets::Cfn::Builders::ParentBuilder.new(@options).build
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def build_api_gateway_templates
|
|
58
|
+
Jets::Cfn::Builders::ApiGatewayBuilder.new(@options).build
|
|
59
|
+
Jets::Cfn::Builders::ApiDeploymentBuilder.new(@options).build
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def build_app_child_templates
|
|
63
|
+
app_files.each do |path|
|
|
64
|
+
build_child_template(path)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def build_shared_resources_templates
|
|
69
|
+
Jets::Stack.subclasses.each do |subclass|
|
|
70
|
+
Jets::Cfn::Builders::SharedBuilder.new(subclass).build
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# path: app/controllers/comments_controller.rb
|
|
75
|
+
# path: app/jobs/easy_job.rb
|
|
76
|
+
def build_child_template(path)
|
|
77
|
+
md = path.match(%r{app/(.*?)/}) # extract: controller, job or function
|
|
78
|
+
process_class = md[1].classify
|
|
79
|
+
builder_class = "Jets::Cfn::Builders::#{process_class}Builder".constantize
|
|
80
|
+
|
|
81
|
+
# Examples:
|
|
82
|
+
# Jets::Cfn::Builders::ControllerBuilder.new(PostsController)
|
|
83
|
+
# Jets::Cfn::Builders::JobBuilder.new(EasyJob)
|
|
84
|
+
# Jets::Cfn::Builders::RuleBuilder.new(CheckRule)
|
|
85
|
+
# Jets::Cfn::Builders::FunctionBuilder.new(Hello)
|
|
86
|
+
# Jets::Cfn::Builders::FunctionBuilder.new(HelloFunction)
|
|
87
|
+
app_class = Jets::Klass.from_path(path)
|
|
88
|
+
builder = builder_class.new(app_class)
|
|
89
|
+
unless Jets.poly_only? && app_class == Jets::PreheatJob
|
|
90
|
+
builder.build
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def build_parent_template
|
|
95
|
+
Jets::Cfn::Builders::ParentBuilder.new(@options).build
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def clean_templates
|
|
99
|
+
FileUtils.rm_rf("#{Jets.build_root}/templates")
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def app_files
|
|
103
|
+
self.class.app_files
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Crucial that the Dir.pwd is in the tmp_code because for
|
|
107
|
+
# because Jets.boot set ups autoload_paths and this is how project
|
|
108
|
+
# classes are loaded.
|
|
109
|
+
# TODO: rework code so that Dir.pwd does not have to be in tmp_code for build to work.
|
|
110
|
+
def self.app_files
|
|
111
|
+
paths = []
|
|
112
|
+
expression = "#{Jets.root}/app/**/**/*.rb"
|
|
113
|
+
Dir.glob(expression).each do |path|
|
|
114
|
+
return false unless File.file?(path)
|
|
115
|
+
next unless app_file?(path)
|
|
116
|
+
|
|
117
|
+
relative_path = path.sub("#{Jets.root}/", '')
|
|
118
|
+
# Rids of the Jets.root at beginning
|
|
119
|
+
paths << relative_path
|
|
120
|
+
end
|
|
121
|
+
paths += internal_app_files
|
|
122
|
+
paths
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def shared_files
|
|
126
|
+
self.class.shared_files
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def self.shared_files
|
|
130
|
+
paths = []
|
|
131
|
+
expression = "#{Jets.root}/app/**/**/*.rb"
|
|
132
|
+
Dir.glob(expression).each do |path|
|
|
133
|
+
return false unless File.file?(path)
|
|
134
|
+
next unless path.include?("app/shared/resources")
|
|
135
|
+
|
|
136
|
+
relative_path = path.sub("#{Jets.root}/", '')
|
|
137
|
+
# Rids of the Jets.root at beginning
|
|
138
|
+
paths << relative_path
|
|
139
|
+
end
|
|
140
|
+
paths
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Finds out of the app has polymorphic functions only and zero ruby functions.
|
|
144
|
+
# In this case, we can skip a lot of the ruby related building and speed up the
|
|
145
|
+
# deploy process.
|
|
146
|
+
def self.poly_only?
|
|
147
|
+
!app_has_ruby? && !shared_has_ruby?
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def self.app_has_ruby?
|
|
151
|
+
has_ruby = app_files.detect do |path|
|
|
152
|
+
app_class = Jets::Klass.from_path(path) # IE: PostsController, Jets::PublicController
|
|
153
|
+
langs = app_class.tasks.map(&:lang)
|
|
154
|
+
langs.include?(:ruby) && app_class != Jets::PreheatJob
|
|
155
|
+
end
|
|
156
|
+
!!has_ruby
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def self.shared_has_ruby?
|
|
160
|
+
has_ruby = false
|
|
161
|
+
Jets::Stack.subclasses.each do |klass|
|
|
162
|
+
klass.functions.each do |fun|
|
|
163
|
+
if fun.lang == :ruby
|
|
164
|
+
has_ruby = true
|
|
165
|
+
break
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
has_ruby
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Add internal Jets controllers if they are being used
|
|
173
|
+
def self.internal_app_files
|
|
174
|
+
paths = []
|
|
175
|
+
controllers = File.expand_path("../../internal/app/controllers/jets", __FILE__)
|
|
176
|
+
|
|
177
|
+
public_catchall = Jets::Router.has_controller?("Jets::PublicController")
|
|
178
|
+
paths << "#{controllers}/public_controller.rb" if public_catchall
|
|
179
|
+
|
|
180
|
+
rack_catchall = Jets::Router.has_controller?("Jets::RackController")
|
|
181
|
+
paths << "#{controllers}/rack_controller.rb" if rack_catchall
|
|
182
|
+
|
|
183
|
+
if Jets.config.prewarm.enable
|
|
184
|
+
jobs = File.expand_path("../../internal/app/jobs/jets", __FILE__)
|
|
185
|
+
paths << "#{jobs}/preheat_job.rb"
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
paths
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def self.app_file?(path)
|
|
192
|
+
return false unless File.extname(path) == ".rb"
|
|
193
|
+
# Do not define lamda functions for the application_controller.rb or
|
|
194
|
+
# application_job.rb
|
|
195
|
+
excludes = %w[
|
|
196
|
+
application_controller.rb
|
|
197
|
+
application_job.rb
|
|
198
|
+
]
|
|
199
|
+
return false if excludes.detect { |p| path.include?(p) }
|
|
200
|
+
|
|
201
|
+
includes = %w[
|
|
202
|
+
app/controllers
|
|
203
|
+
app/jobs
|
|
204
|
+
app/functions
|
|
205
|
+
app/rules
|
|
206
|
+
]
|
|
207
|
+
return true if includes.detect { |p| path.include?(p) }
|
|
208
|
+
|
|
209
|
+
false
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def self.tmp_code(full_build_path=false)
|
|
213
|
+
full_build_path ? "#{Jets.build_root}/stage/code" : "stage/code"
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
end
|
|
217
|
+
end
|