@shopify/cli-kit 3.69.4 → 3.71.0
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.
- package/{assets/cli-ruby/LICENSE → LICENSE} +0 -2
- package/dist/cli/api/graphql/admin/generated/get_theme_file_bodies.d.ts +41 -0
- package/dist/cli/api/graphql/admin/generated/get_theme_file_bodies.js +165 -0
- package/dist/cli/api/graphql/admin/generated/get_theme_file_bodies.js.map +1 -0
- package/dist/cli/api/graphql/admin/generated/get_theme_file_checksums.d.ts +29 -0
- package/dist/cli/api/graphql/admin/generated/get_theme_file_checksums.js +100 -0
- package/dist/cli/api/graphql/admin/generated/get_theme_file_checksums.js.map +1 -0
- package/dist/cli/api/graphql/admin/generated/theme_delete.d.ts +17 -0
- package/dist/cli/api/graphql/admin/generated/theme_delete.js +53 -0
- package/dist/cli/api/graphql/admin/generated/theme_delete.js.map +1 -0
- package/dist/cli/api/graphql/admin/generated/theme_files_upsert.d.ts +21 -0
- package/dist/cli/api/graphql/admin/generated/theme_files_upsert.js +82 -0
- package/dist/cli/api/graphql/admin/generated/theme_files_upsert.js.map +1 -0
- package/dist/cli/api/graphql/admin/generated/theme_publish.d.ts +21 -0
- package/dist/cli/api/graphql/admin/generated/theme_publish.js +65 -0
- package/dist/cli/api/graphql/admin/generated/theme_publish.js.map +1 -0
- package/dist/cli/api/graphql/admin/generated/theme_update.d.ts +23 -0
- package/dist/cli/api/graphql/admin/generated/theme_update.js +75 -0
- package/dist/cli/api/graphql/admin/generated/theme_update.js.map +1 -0
- package/dist/private/node/api/graphql.d.ts +2 -2
- package/dist/private/node/api/graphql.js +4 -4
- package/dist/private/node/api/graphql.js.map +1 -1
- package/dist/private/node/api/headers.js +1 -1
- package/dist/private/node/api/headers.js.map +1 -1
- package/dist/private/node/api/rest.d.ts +1 -2
- package/dist/private/node/api/rest.js +2 -3
- package/dist/private/node/api/rest.js.map +1 -1
- package/dist/private/node/api.d.ts +1 -1
- package/dist/private/node/api.js +41 -2
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/conf-store.d.ts +9 -4
- package/dist/private/node/conf-store.js +8 -6
- package/dist/private/node/conf-store.js.map +1 -1
- package/dist/private/node/constants.d.ts +3 -0
- package/dist/private/node/constants.js +3 -0
- package/dist/private/node/constants.js.map +1 -1
- package/dist/private/node/session/exchange.js +2 -2
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/session/schema.d.ts +40 -40
- package/dist/private/node/session/scopes.js +3 -5
- package/dist/private/node/session/scopes.js.map +1 -1
- package/dist/private/node/session.js +2 -3
- package/dist/private/node/session.js.map +1 -1
- package/dist/private/node/ui/alert.js +1 -3
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +1 -0
- package/dist/private/node/ui/components/ConcurrentOutput.js +4 -4
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/Link.js +3 -0
- package/dist/private/node/ui/components/Link.js.map +1 -1
- package/dist/private/node/ui/components/Link.test.js +23 -0
- package/dist/private/node/ui/components/Link.test.js.map +1 -1
- package/dist/private/node/ui.js +1 -1
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/analytics.js +1 -2
- package/dist/public/node/analytics.js.map +1 -1
- package/dist/public/node/api/admin.d.ts +2 -1
- package/dist/public/node/api/admin.js +36 -10
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/graphql.d.ts +2 -0
- package/dist/public/node/api/graphql.js +3 -3
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/api/webhooks.d.ts +13 -0
- package/dist/public/node/api/webhooks.js +34 -0
- package/dist/public/node/api/webhooks.js.map +1 -0
- package/dist/public/node/base-command.js +4 -0
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/cli-launcher.d.ts +12 -0
- package/dist/public/node/cli-launcher.js +29 -0
- package/dist/public/node/cli-launcher.js.map +1 -0
- package/dist/public/node/cli.d.ts +16 -10
- package/dist/public/node/cli.js +45 -101
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/context/fqdn.js +11 -7
- package/dist/public/node/context/fqdn.js.map +1 -1
- package/dist/public/node/context/local.d.ts +7 -0
- package/dist/public/node/context/local.js +16 -0
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/environment.d.ts +7 -0
- package/dist/public/node/environment.js +11 -0
- package/dist/public/node/environment.js.map +1 -1
- package/dist/public/node/error-handler.js +2 -4
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/error.js +4 -13
- package/dist/public/node/error.js.map +1 -1
- package/dist/public/node/global-context.d.ts +15 -0
- package/dist/public/node/global-context.js +29 -0
- package/dist/public/node/global-context.js.map +1 -0
- package/dist/public/node/hooks/prerun.js +0 -2
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/public/node/is-global.js +2 -1
- package/dist/public/node/is-global.js.map +1 -1
- package/dist/public/node/json-schema.d.ts +2 -1
- package/dist/public/node/json-schema.js +8 -3
- package/dist/public/node/json-schema.js.map +1 -1
- package/dist/public/node/node-package-manager.js +1 -1
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/notifications-system.d.ts +193 -0
- package/dist/public/node/notifications-system.js +242 -0
- package/dist/public/node/notifications-system.js.map +1 -0
- package/dist/public/node/output.d.ts +1 -6
- package/dist/public/node/output.js +1 -5
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/path.d.ts +3 -3
- package/dist/public/node/path.js +4 -5
- package/dist/public/node/path.js.map +1 -1
- package/dist/public/node/system.js +14 -2
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/themes/api.d.ts +4 -12
- package/dist/public/node/themes/api.js +225 -36
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/public/node/themes/factories.d.ts +1 -3
- package/dist/public/node/themes/factories.js +0 -16
- package/dist/public/node/themes/factories.js.map +1 -1
- package/dist/public/node/themes/types.d.ts +1 -0
- package/dist/public/node/themes/types.js.map +1 -1
- package/dist/public/node/themes/utils.d.ts +2 -0
- package/dist/public/node/themes/utils.js +11 -0
- package/dist/public/node/themes/utils.js.map +1 -1
- package/dist/public/node/tree-kill.js +0 -2
- package/dist/public/node/tree-kill.js.map +1 -1
- package/dist/public/node/ui.js +30 -80
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/vendor/dev_server/DevServer.d.ts +19 -0
- package/dist/public/node/vendor/dev_server/DevServer.js +170 -0
- package/dist/public/node/vendor/dev_server/DevServer.js.map +1 -0
- package/dist/public/node/version.d.ts +13 -0
- package/dist/public/node/version.js +38 -0
- package/dist/public/node/version.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -7
- package/assets/cli-ruby/.devcontainer.json +0 -5
- package/assets/cli-ruby/.rubocop.yml +0 -102
- package/assets/cli-ruby/.rubocop_todo.yml +0 -24
- package/assets/cli-ruby/CHANGELOG.md +0 -634
- package/assets/cli-ruby/CONTRIBUTING.md +0 -3
- package/assets/cli-ruby/Codespace.dockerfile +0 -35
- package/assets/cli-ruby/Gemfile +0 -32
- package/assets/cli-ruby/README.md +0 -30
- package/assets/cli-ruby/Rakefile +0 -167
- package/assets/cli-ruby/SECURITY.md +0 -59
- package/assets/cli-ruby/Tests.dockerfile +0 -35
- package/assets/cli-ruby/assets/logo.png +0 -0
- package/assets/cli-ruby/bin/console +0 -11
- package/assets/cli-ruby/bin/load_shopify.rb +0 -22
- package/assets/cli-ruby/bin/shopify +0 -67
- package/assets/cli-ruby/bin/shopify.bat +0 -3
- package/assets/cli-ruby/dev.yml +0 -29
- package/assets/cli-ruby/docs/README.md +0 -13
- package/assets/cli-ruby/docs/contributors/testing.md +0 -27
- package/assets/cli-ruby/docs/users/installation.md +0 -3
- package/assets/cli-ruby/docs/users/migrate-from-themekit.md +0 -18
- package/assets/cli-ruby/ext/javy/hashes/javy-arm-macos-v0.1.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-arm-macos-v0.2.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-arm-macos-v0.2.1.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-arm-macos-v0.3.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-linux-v0.1.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-linux-v0.2.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-linux-v0.2.1.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-linux-v0.3.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-macos-v0.1.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-macos-v0.2.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-macos-v0.2.1.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-macos-v0.3.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-windows-v0.1.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-windows-v0.2.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-windows-v0.2.1.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-windows-v0.3.0.gz.sha256 +0 -1
- package/assets/cli-ruby/ext/javy/javy.rb +0 -204
- package/assets/cli-ruby/ext/javy/version +0 -1
- package/assets/cli-ruby/ext/shopify-extensions/extconf.rb +0 -21
- package/assets/cli-ruby/ext/shopify-extensions/shopify_extensions.rb +0 -152
- package/assets/cli-ruby/ext/shopify-extensions/version +0 -1
- package/assets/cli-ruby/features/support/assertions.rb +0 -17
- package/assets/cli-ruby/features/support/cli.rb +0 -7
- package/assets/cli-ruby/features/support/process.rb +0 -27
- package/assets/cli-ruby/features/support/requires.rb +0 -3
- package/assets/cli-ruby/lib/docgen/class_template.md.erb +0 -81
- package/assets/cli-ruby/lib/docgen/index_template.md.erb +0 -5
- package/assets/cli-ruby/lib/docgen/markdown.rb +0 -101
- package/assets/cli-ruby/lib/graphql/admin_introspection.graphql +0 -87
- package/assets/cli-ruby/lib/graphql/all_organizations.graphql +0 -19
- package/assets/cli-ruby/lib/graphql/all_orgs_with_apps.graphql +0 -30
- package/assets/cli-ruby/lib/graphql/api_versions.graphql +0 -6
- package/assets/cli-ruby/lib/graphql/convert_dev_to_test_store.graphql +0 -10
- package/assets/cli-ruby/lib/graphql/create_app.graphql +0 -20
- package/assets/cli-ruby/lib/graphql/create_customer.graphql +0 -9
- package/assets/cli-ruby/lib/graphql/create_draft_order.graphql +0 -8
- package/assets/cli-ruby/lib/graphql/create_product.graphql +0 -9
- package/assets/cli-ruby/lib/graphql/extension_create.graphql +0 -37
- package/assets/cli-ruby/lib/graphql/extension_update_draft.graphql +0 -19
- package/assets/cli-ruby/lib/graphql/fetch_specifications.graphql +0 -14
- package/assets/cli-ruby/lib/graphql/find_organization.graphql +0 -18
- package/assets/cli-ruby/lib/graphql/find_organization_with_apps.graphql +0 -20
- package/assets/cli-ruby/lib/graphql/get_app_by_api_key.graphql +0 -9
- package/assets/cli-ruby/lib/graphql/get_app_urls.graphql +0 -6
- package/assets/cli-ruby/lib/graphql/get_extension_registrations.graphql +0 -28
- package/assets/cli-ruby/lib/graphql/get_variant_id.graphql +0 -16
- package/assets/cli-ruby/lib/graphql/update_dashboard_urls.graphql +0 -8
- package/assets/cli-ruby/lib/project_types/extension/cli.rb +0 -75
- package/assets/cli-ruby/lib/project_types/extension/commands/extension_command.rb +0 -29
- package/assets/cli-ruby/lib/project_types/extension/commands/serve.rb +0 -164
- package/assets/cli-ruby/lib/project_types/extension/errors.rb +0 -9
- package/assets/cli-ruby/lib/project_types/extension/extension_project.rb +0 -151
- package/assets/cli-ruby/lib/project_types/extension/extension_project_keys.rb +0 -12
- package/assets/cli-ruby/lib/project_types/extension/features/argo.rb +0 -50
- package/assets/cli-ruby/lib/project_types/extension/features/argo_config.rb +0 -59
- package/assets/cli-ruby/lib/project_types/extension/features/argo_dependencies.rb +0 -28
- package/assets/cli-ruby/lib/project_types/extension/features/argo_runtime.rb +0 -15
- package/assets/cli-ruby/lib/project_types/extension/features/argo_serve.rb +0 -115
- package/assets/cli-ruby/lib/project_types/extension/features/argo_setup.rb +0 -54
- package/assets/cli-ruby/lib/project_types/extension/features/argo_setup_step.rb +0 -31
- package/assets/cli-ruby/lib/project_types/extension/features/argo_setup_steps.rb +0 -51
- package/assets/cli-ruby/lib/project_types/extension/features/runtimes/admin.rb +0 -29
- package/assets/cli-ruby/lib/project_types/extension/features/runtimes/base.rb +0 -19
- package/assets/cli-ruby/lib/project_types/extension/features/runtimes/checkout_post_purchase.rb +0 -23
- package/assets/cli-ruby/lib/project_types/extension/features/runtimes/checkout_ui_extension.rb +0 -29
- package/assets/cli-ruby/lib/project_types/extension/loaders/project.rb +0 -50
- package/assets/cli-ruby/lib/project_types/extension/loaders/specification_handler.rb +0 -22
- package/assets/cli-ruby/lib/project_types/extension/messages/message_loading.rb +0 -34
- package/assets/cli-ruby/lib/project_types/extension/messages/messages.rb +0 -320
- package/assets/cli-ruby/lib/project_types/extension/models/app.rb +0 -14
- package/assets/cli-ruby/lib/project_types/extension/models/lazy_specification_handler.rb +0 -12
- package/assets/cli-ruby/lib/project_types/extension/models/specification.rb +0 -41
- package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/default.rb +0 -145
- package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +0 -134
- package/assets/cli-ruby/lib/project_types/extension/models/specifications.rb +0 -91
- package/assets/cli-ruby/lib/project_types/extension/models/validation_error.rb +0 -17
- package/assets/cli-ruby/lib/project_types/extension/models/version.rb +0 -15
- package/assets/cli-ruby/lib/project_types/extension/tasks/configure_features.rb +0 -73
- package/assets/cli-ruby/lib/project_types/extension/tasks/configure_options.rb +0 -21
- package/assets/cli-ruby/lib/project_types/extension/tasks/converters/validation_error_converter.rb +0 -25
- package/assets/cli-ruby/lib/project_types/extension/tasks/converters/version_converter.rb +0 -28
- package/assets/cli-ruby/lib/project_types/extension/tasks/fetch_specifications.rb +0 -21
- package/assets/cli-ruby/lib/project_types/node/cli.rb +0 -12
- package/assets/cli-ruby/lib/project_types/node/forms/create.rb +0 -45
- package/assets/cli-ruby/lib/project_types/node/messages/messages.rb +0 -33
- package/assets/cli-ruby/lib/project_types/php/cli.rb +0 -16
- package/assets/cli-ruby/lib/project_types/php/forms/create.rb +0 -44
- package/assets/cli-ruby/lib/project_types/php/messages/messages.rb +0 -29
- package/assets/cli-ruby/lib/project_types/rails/cli.rb +0 -15
- package/assets/cli-ruby/lib/project_types/rails/forms/create.rb +0 -75
- package/assets/cli-ruby/lib/project_types/rails/gem.rb +0 -110
- package/assets/cli-ruby/lib/project_types/rails/messages/messages.rb +0 -101
- package/assets/cli-ruby/lib/project_types/script/cli.rb +0 -27
- package/assets/cli-ruby/lib/project_types/script/commands/connect.rb +0 -16
- package/assets/cli-ruby/lib/project_types/script/commands/create.rb +0 -24
- package/assets/cli-ruby/lib/project_types/script/commands/javy.rb +0 -24
- package/assets/cli-ruby/lib/project_types/script/commands/push.rb +0 -26
- package/assets/cli-ruby/lib/project_types/script/loaders/project.rb +0 -46
- package/assets/cli-ruby/lib/project_types/script/loaders/specification_handler.rb +0 -22
- package/assets/cli-ruby/lib/project_types/script/messages/messages.rb +0 -11
- package/assets/cli-ruby/lib/project_types/theme/cli.rb +0 -33
- package/assets/cli-ruby/lib/project_types/theme/commands/common/root_helper.rb +0 -94
- package/assets/cli-ruby/lib/project_types/theme/commands/common/shop_helper.rb +0 -13
- package/assets/cli-ruby/lib/project_types/theme/commands/console.rb +0 -23
- package/assets/cli-ruby/lib/project_types/theme/commands/delete.rb +0 -70
- package/assets/cli-ruby/lib/project_types/theme/commands/init.rb +0 -46
- package/assets/cli-ruby/lib/project_types/theme/commands/list.rb +0 -33
- package/assets/cli-ruby/lib/project_types/theme/commands/open.rb +0 -73
- package/assets/cli-ruby/lib/project_types/theme/commands/package.rb +0 -73
- package/assets/cli-ruby/lib/project_types/theme/commands/publish.rb +0 -49
- package/assets/cli-ruby/lib/project_types/theme/commands/pull.rb +0 -118
- package/assets/cli-ruby/lib/project_types/theme/commands/push.rb +0 -160
- package/assets/cli-ruby/lib/project_types/theme/commands/serve.rb +0 -91
- package/assets/cli-ruby/lib/project_types/theme/commands/share.rb +0 -62
- package/assets/cli-ruby/lib/project_types/theme/commands/token.rb +0 -22
- package/assets/cli-ruby/lib/project_types/theme/conversions/base_glob.rb +0 -65
- package/assets/cli-ruby/lib/project_types/theme/conversions/ignore_glob.rb +0 -15
- package/assets/cli-ruby/lib/project_types/theme/conversions/include_glob.rb +0 -15
- package/assets/cli-ruby/lib/project_types/theme/forms/confirm_store.rb +0 -15
- package/assets/cli-ruby/lib/project_types/theme/forms/select.rb +0 -34
- package/assets/cli-ruby/lib/project_types/theme/messages/messages.rb +0 -429
- package/assets/cli-ruby/lib/project_types/theme/models/specification_handlers/theme.rb +0 -19
- package/assets/cli-ruby/lib/project_types/theme/presenters/theme_presenter.rb +0 -48
- package/assets/cli-ruby/lib/project_types/theme/presenters/themes_presenter.rb +0 -29
- package/assets/cli-ruby/lib/project_types/theme/ui/sync_progress_bar.rb +0 -20
- package/assets/cli-ruby/lib/rubygems_plugin.rb +0 -26
- package/assets/cli-ruby/lib/shopify_cli/admin_api.rb +0 -160
- package/assets/cli-ruby/lib/shopify_cli/api.rb +0 -130
- package/assets/cli-ruby/lib/shopify_cli/command/project_command.rb +0 -31
- package/assets/cli-ruby/lib/shopify_cli/command/sub_command.rb +0 -20
- package/assets/cli-ruby/lib/shopify_cli/command.rb +0 -166
- package/assets/cli-ruby/lib/shopify_cli/commands.rb +0 -21
- package/assets/cli-ruby/lib/shopify_cli/constants.rb +0 -101
- package/assets/cli-ruby/lib/shopify_cli/context.rb +0 -709
- package/assets/cli-ruby/lib/shopify_cli/core/cli_version.rb +0 -20
- package/assets/cli-ruby/lib/shopify_cli/core/entry_point.rb +0 -64
- package/assets/cli-ruby/lib/shopify_cli/core/executor.rb +0 -23
- package/assets/cli-ruby/lib/shopify_cli/core/finalize.rb +0 -13
- package/assets/cli-ruby/lib/shopify_cli/core/monorail.rb +0 -122
- package/assets/cli-ruby/lib/shopify_cli/core.rb +0 -8
- package/assets/cli-ruby/lib/shopify_cli/db.rb +0 -114
- package/assets/cli-ruby/lib/shopify_cli/environment.rb +0 -217
- package/assets/cli-ruby/lib/shopify_cli/exception_reporter.rb +0 -80
- package/assets/cli-ruby/lib/shopify_cli/feature.rb +0 -95
- package/assets/cli-ruby/lib/shopify_cli/file_system_listener.rb +0 -30
- package/assets/cli-ruby/lib/shopify_cli/form.rb +0 -42
- package/assets/cli-ruby/lib/shopify_cli/git.rb +0 -320
- package/assets/cli-ruby/lib/shopify_cli/github/issue_url_generator.rb +0 -30
- package/assets/cli-ruby/lib/shopify_cli/github.rb +0 -5
- package/assets/cli-ruby/lib/shopify_cli/helpers/haikunator.rb +0 -92
- package/assets/cli-ruby/lib/shopify_cli/helpers.rb +0 -5
- package/assets/cli-ruby/lib/shopify_cli/http_request.rb +0 -43
- package/assets/cli-ruby/lib/shopify_cli/identity_auth/env_auth_token.rb +0 -34
- package/assets/cli-ruby/lib/shopify_cli/identity_auth.rb +0 -332
- package/assets/cli-ruby/lib/shopify_cli/js_system.rb +0 -115
- package/assets/cli-ruby/lib/shopify_cli/lazy_delegator.rb +0 -55
- package/assets/cli-ruby/lib/shopify_cli/messages/messages.rb +0 -863
- package/assets/cli-ruby/lib/shopify_cli/method_object.rb +0 -123
- package/assets/cli-ruby/lib/shopify_cli/migrator/migration.rb +0 -27
- package/assets/cli-ruby/lib/shopify_cli/migrator/migrations/1631709766_noop.rb +0 -13
- package/assets/cli-ruby/lib/shopify_cli/migrator/migrations/1633691650_merge_reporting_configuration.rb +0 -41
- package/assets/cli-ruby/lib/shopify_cli/migrator.rb +0 -46
- package/assets/cli-ruby/lib/shopify_cli/options.rb +0 -40
- package/assets/cli-ruby/lib/shopify_cli/partners_api/app_extensions/job.rb +0 -36
- package/assets/cli-ruby/lib/shopify_cli/partners_api/app_extensions.rb +0 -46
- package/assets/cli-ruby/lib/shopify_cli/partners_api/organizations.rb +0 -45
- package/assets/cli-ruby/lib/shopify_cli/partners_api.rb +0 -91
- package/assets/cli-ruby/lib/shopify_cli/project.rb +0 -199
- package/assets/cli-ruby/lib/shopify_cli/project_type.rb +0 -66
- package/assets/cli-ruby/lib/shopify_cli/reporting_configuration_controller.rb +0 -29
- package/assets/cli-ruby/lib/shopify_cli/resolve_constant.rb +0 -25
- package/assets/cli-ruby/lib/shopify_cli/resources/env_file.rb +0 -108
- package/assets/cli-ruby/lib/shopify_cli/resources.rb +0 -5
- package/assets/cli-ruby/lib/shopify_cli/result.rb +0 -448
- package/assets/cli-ruby/lib/shopify_cli/shopifolk.rb +0 -82
- package/assets/cli-ruby/lib/shopify_cli/task.rb +0 -20
- package/assets/cli-ruby/lib/shopify_cli/tasks/confirm_store.rb +0 -18
- package/assets/cli-ruby/lib/shopify_cli/tasks/create_api_client.rb +0 -40
- package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_authenticated.rb +0 -19
- package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_dev_store.rb +0 -41
- package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_env.rb +0 -90
- package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_git_dependency.rb +0 -14
- package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_loopback_url.rb +0 -20
- package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_project_type.rb +0 -14
- package/assets/cli-ruby/lib/shopify_cli/tasks/select_org_and_shop.rb +0 -81
- package/assets/cli-ruby/lib/shopify_cli/tasks/update_dashboard_urls.rb +0 -57
- package/assets/cli-ruby/lib/shopify_cli/tasks.rb +0 -44
- package/assets/cli-ruby/lib/shopify_cli/theme/backoff_helper.rb +0 -47
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +0 -82
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/certificate_manager.rb +0 -79
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/errors.rb +0 -9
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/header_hash.rb +0 -98
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hooks/file_change_hook.rb +0 -77
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_deleter.rb +0 -62
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb +0 -63
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/resources/hot-reload-no-script.html +0 -27
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/resources/hot_reload.js +0 -48
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/resources/sse_client.js +0 -43
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/resources/theme.js +0 -114
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/resources/theme_extension.js +0 -121
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/script_injector.rb +0 -57
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/sections_index.rb +0 -50
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload.rb +0 -75
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/local_assets.rb +0 -101
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy.rb +0 -313
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy_param_builder.rb +0 -84
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/reload_mode.rb +0 -34
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/remote_watcher/json_files_update_job.rb +0 -35
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/remote_watcher.rb +0 -44
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/sse.rb +0 -75
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/watcher.rb +0 -64
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/web_server.rb +0 -140
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server.rb +0 -332
- package/assets/cli-ruby/lib/shopify_cli/theme/development_theme.rb +0 -101
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/app_extension.rb +0 -40
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb +0 -76
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/hot_reload/script_injector.rb +0 -30
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/hot_reload.rb +0 -13
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/local_assets.rb +0 -31
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/proxy_param_builder.rb +0 -94
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/watcher.rb +0 -49
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server.rb +0 -175
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/host_theme.rb +0 -109
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/ignore_helper.rb +0 -35
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/syncer/extension_serve_job.rb +0 -120
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/syncer/operation.rb +0 -25
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/syncer.rb +0 -100
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb +0 -35
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/ui/host_theme_raw_progress_bar.rb +0 -40
- package/assets/cli-ruby/lib/shopify_cli/theme/file.rb +0 -133
- package/assets/cli-ruby/lib/shopify_cli/theme/filter/path_matcher.rb +0 -38
- package/assets/cli-ruby/lib/shopify_cli/theme/ignore_filter.rb +0 -112
- package/assets/cli-ruby/lib/shopify_cli/theme/ignore_helper.rb +0 -37
- package/assets/cli-ruby/lib/shopify_cli/theme/include_filter.rb +0 -67
- package/assets/cli-ruby/lib/shopify_cli/theme/mime_type.rb +0 -34
- package/assets/cli-ruby/lib/shopify_cli/theme/notifier.rb +0 -52
- package/assets/cli-ruby/lib/shopify_cli/theme/repl/api.rb +0 -109
- package/assets/cli-ruby/lib/shopify_cli/theme/repl/auth_dev_server.rb +0 -93
- package/assets/cli-ruby/lib/shopify_cli/theme/repl/auth_middleware.rb +0 -97
- package/assets/cli-ruby/lib/shopify_cli/theme/repl/remote_evaluator.rb +0 -166
- package/assets/cli-ruby/lib/shopify_cli/theme/repl/resources/success.html +0 -78
- package/assets/cli-ruby/lib/shopify_cli/theme/repl/resources/template.liquid +0 -15
- package/assets/cli-ruby/lib/shopify_cli/theme/repl/snippet.rb +0 -81
- package/assets/cli-ruby/lib/shopify_cli/theme/repl.rb +0 -88
- package/assets/cli-ruby/lib/shopify_cli/theme/root.rb +0 -62
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/checksums.rb +0 -66
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/downloader.rb +0 -63
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/error_reporter.rb +0 -45
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/merger.rb +0 -53
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/operation.rb +0 -49
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/standard_reporter.rb +0 -32
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/unsupported_script_warning.rb +0 -90
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/bulk.rb +0 -133
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/bulk_item.rb +0 -64
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/bulk_job.rb +0 -139
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/bulk_request.rb +0 -30
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/forms/apply_to_all.rb +0 -41
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/forms/apply_to_all_form.rb +0 -37
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/forms/base_strategy_form.rb +0 -64
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/forms/select_delete_strategy.rb +0 -29
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/forms/select_update_strategy.rb +0 -30
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/json_delete_handler.rb +0 -49
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/json_update_handler.rb +0 -71
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader.rb +0 -231
- package/assets/cli-ruby/lib/shopify_cli/theme/syncer.rb +0 -391
- package/assets/cli-ruby/lib/shopify_cli/theme/theme.rb +0 -212
- package/assets/cli-ruby/lib/shopify_cli/theme/theme_access_api.rb +0 -89
- package/assets/cli-ruby/lib/shopify_cli/theme/theme_admin_api.rb +0 -101
- package/assets/cli-ruby/lib/shopify_cli/thread_pool/job.rb +0 -35
- package/assets/cli-ruby/lib/shopify_cli/thread_pool.rb +0 -49
- package/assets/cli-ruby/lib/shopify_cli/transform_data_structure.rb +0 -87
- package/assets/cli-ruby/lib/shopify_cli/utilities.rb +0 -21
- package/assets/cli-ruby/lib/shopify_cli/version.rb +0 -3
- package/assets/cli-ruby/lib/shopify_cli.rb +0 -182
- package/assets/cli-ruby/shipit.rubygems.yml +0 -3
- package/assets/cli-ruby/shopify-cli.gemspec +0 -46
- package/assets/cli-ruby/shopify-dev +0 -16
- package/assets/cli-ruby/test/minitest_ext.rb +0 -115
- package/assets/cli-ruby/test/project_types/extension/extension_test_helpers.rb +0 -70
- package/assets/cli-ruby/test/shopify-cli/migrator/migrations/migration_helper.rb +0 -20
- package/assets/cli-ruby/test/test_helpers.rb +0 -16
- package/assets/cli-ruby/utilities/constants.rb +0 -7
- package/assets/cli-ruby/utilities/docker/container.rb +0 -104
- package/assets/cli-ruby/utilities/docker.rb +0 -89
- package/assets/cli-ruby/utilities/utilities.rb +0 -6
- package/assets/cli-ruby/vendor/deps/cli-kit/REVISION +0 -1
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/autocall.rb +0 -21
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +0 -49
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +0 -94
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/config.rb +0 -133
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +0 -123
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/executor.rb +0 -79
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/ini.rb +0 -102
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +0 -82
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/logger.rb +0 -82
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +0 -60
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/ruby_backports/enumerable.rb +0 -6
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +0 -244
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/support.rb +0 -9
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/system.rb +0 -243
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/util.rb +0 -193
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/version.rb +0 -5
- package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit.rb +0 -60
- package/assets/cli-ruby/vendor/deps/cli-ui/REVISION +0 -1
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +0 -157
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/color.rb +0 -84
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +0 -193
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +0 -98
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +0 -166
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +0 -139
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +0 -120
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/frame.rb +0 -269
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +0 -84
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/os.rb +0 -73
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/printer.rb +0 -59
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/progress.rb +0 -90
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/progress_plain.rb +0 -50
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +0 -484
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +0 -29
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +0 -282
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +0 -40
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +0 -263
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +0 -66
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +0 -232
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +0 -46
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +0 -102
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/version.rb +0 -5
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +0 -27
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +0 -61
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +0 -77
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +0 -56
- package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui.rb +0 -234
- package/assets/cli-ruby/vendor/deps/ruby2_keywords/LICENSE +0 -22
- package/assets/cli-ruby/vendor/deps/ruby2_keywords/README.md +0 -67
- package/assets/cli-ruby/vendor/deps/ruby2_keywords/Rakefile +0 -54
- package/assets/cli-ruby/vendor/deps/ruby2_keywords/lib/ruby2_keywords.rb +0 -57
- package/assets/cli-ruby/vendor/deps/ruby2_keywords/ruby2_keywords.gemspec +0 -18
- package/assets/cli-ruby/vendor/deps/ruby2_keywords/test/test_keyword.rb +0 -41
- package/assets/cli-ruby/vendor/deps/smart_properties/REVISION +0 -1
- package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/errors.rb +0 -114
- package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/property.rb +0 -168
- package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/property_collection.rb +0 -83
- package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/validations/ancestor.rb +0 -27
- package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/validations.rb +0 -8
- package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/version.rb +0 -3
- package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties.rb +0 -174
- package/assets/cli-ruby/vendor/deps/webrick/Gemfile +0 -3
- package/assets/cli-ruby/vendor/deps/webrick/LICENSE.txt +0 -22
- package/assets/cli-ruby/vendor/deps/webrick/README.md +0 -61
- package/assets/cli-ruby/vendor/deps/webrick/Rakefile +0 -10
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/accesslog.rb +0 -157
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/cgi.rb +0 -313
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/compat.rb +0 -36
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/config.rb +0 -158
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/cookie.rb +0 -172
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/htmlutils.rb +0 -30
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +0 -117
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +0 -116
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +0 -395
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +0 -132
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +0 -97
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +0 -158
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +0 -53
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth.rb +0 -96
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpproxy.rb +0 -354
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httprequest.rb +0 -636
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpresponse.rb +0 -564
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/https.rb +0 -152
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpserver.rb +0 -294
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +0 -152
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +0 -47
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +0 -126
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +0 -88
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +0 -552
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +0 -47
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet.rb +0 -23
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpstatus.rb +0 -194
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httputils.rb +0 -512
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpversion.rb +0 -76
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/log.rb +0 -156
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/server.rb +0 -381
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/ssl.rb +0 -215
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/utils.rb +0 -265
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/version.rb +0 -18
- package/assets/cli-ruby/vendor/deps/webrick/lib/webrick.rb +0 -232
- package/assets/cli-ruby/vendor/deps/webrick/webrick.gemspec +0 -74
- package/assets/cli-ruby/vendor/gen/lib/gen/commands/help.rb +0 -20
- package/assets/cli-ruby/vendor/gen/lib/gen/commands/new.rb +0 -21
- package/assets/cli-ruby/vendor/gen/lib/gen/commands.rb +0 -18
- package/assets/cli-ruby/vendor/gen/lib/gen/entry_point.rb +0 -10
- package/assets/cli-ruby/vendor/gen/lib/gen/generator.rb +0 -165
- package/assets/cli-ruby/vendor/gen/lib/gen.rb +0 -39
- package/assets/cli-ruby/vendor/gen/template/Gemfile +0 -10
- package/assets/cli-ruby/vendor/gen/template/README.md +0 -1
- package/assets/cli-ruby/vendor/gen/template/bin/testunit +0 -23
- package/assets/cli-ruby/vendor/gen/template/bin/update-deps +0 -97
- package/assets/cli-ruby/vendor/gen/template/dev-gems.yml +0 -3
- package/assets/cli-ruby/vendor/gen/template/dev-vendor.yml +0 -4
- package/assets/cli-ruby/vendor/gen/template/exe/__app__-gems +0 -17
- package/assets/cli-ruby/vendor/gen/template/exe/__app__-vendor +0 -18
- package/assets/cli-ruby/vendor/gen/template/lib/__app__/commands/example.rb +0 -19
- package/assets/cli-ruby/vendor/gen/template/lib/__app__/commands/help.rb +0 -21
- package/assets/cli-ruby/vendor/gen/template/lib/__app__/commands.rb +0 -18
- package/assets/cli-ruby/vendor/gen/template/lib/__app__/entry_point.rb +0 -10
- package/assets/cli-ruby/vendor/gen/template/lib/__app__.rb +0 -33
- package/assets/cli-ruby/vendor/gen/template/test/example_test.rb +0 -17
- package/assets/cli-ruby/vendor/gen/template/test/test_helper.rb +0 -22
- package/assets/cli-ruby/vendor/lib/semantic/LICENSE +0 -20
- package/assets/cli-ruby/vendor/lib/semantic/semantic.rb +0 -4
- package/assets/cli-ruby/vendor/lib/semantic/version.rb +0 -179
- package/dist/private/node/demo-recorder.d.ts +0 -17
- package/dist/private/node/demo-recorder.js +0 -121
- package/dist/private/node/demo-recorder.js.map +0 -1
- package/dist/public/node/ruby.d.ts +0 -38
- package/dist/public/node/ruby.js +0 -327
- package/dist/public/node/ruby.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
let _globalContext;
|
|
2
|
+
/**
|
|
3
|
+
* Get the global context.
|
|
4
|
+
*
|
|
5
|
+
* @returns Global context.
|
|
6
|
+
*/
|
|
7
|
+
function getGlobalContext() {
|
|
8
|
+
if (!_globalContext) {
|
|
9
|
+
_globalContext = { currentCommandId: '' };
|
|
10
|
+
}
|
|
11
|
+
return _globalContext;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the current command ID.
|
|
15
|
+
*
|
|
16
|
+
* @returns Current command ID.
|
|
17
|
+
*/
|
|
18
|
+
export function getCurrentCommandId() {
|
|
19
|
+
return getGlobalContext().currentCommandId;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Set the current command ID.
|
|
23
|
+
*
|
|
24
|
+
* @param commandId - Command ID.
|
|
25
|
+
*/
|
|
26
|
+
export function setCurrentCommandId(commandId) {
|
|
27
|
+
getGlobalContext().currentCommandId = commandId;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=global-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-context.js","sourceRoot":"","sources":["../../../src/public/node/global-context.ts"],"names":[],"mappings":"AAIA,IAAI,cAAyC,CAAA;AAE7C;;;;GAIG;AACH,SAAS,gBAAgB;IACvB,IAAI,CAAC,cAAc,EAAE;QACnB,cAAc,GAAG,EAAC,gBAAgB,EAAE,EAAE,EAAC,CAAA;KACxC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,gBAAgB,EAAE,CAAC,gBAAgB,CAAA;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,gBAAgB,EAAE,CAAC,gBAAgB,GAAG,SAAS,CAAA;AACjD,CAAC","sourcesContent":["export interface GlobalContext {\n currentCommandId: string\n}\n\nlet _globalContext: GlobalContext | undefined\n\n/**\n * Get the global context.\n *\n * @returns Global context.\n */\nfunction getGlobalContext(): GlobalContext {\n if (!_globalContext) {\n _globalContext = {currentCommandId: ''}\n }\n return _globalContext\n}\n\n/**\n * Get the current command ID.\n *\n * @returns Current command ID.\n */\nexport function getCurrentCommandId(): string {\n return getGlobalContext().currentCommandId\n}\n\n/**\n * Set the current command ID.\n *\n * @param commandId - Command ID.\n */\nexport function setCurrentCommandId(commandId: string): void {\n getGlobalContext().currentCommandId = commandId\n}\n"]}
|
|
@@ -3,11 +3,9 @@ import { checkForNewVersion, checkForCachedNewVersion } from '../node-package-ma
|
|
|
3
3
|
import { startAnalytics } from '../../../private/node/analytics.js';
|
|
4
4
|
import { outputDebug, outputWarn } from '../../../public/node/output.js';
|
|
5
5
|
import { getOutputUpdateCLIReminder } from '../../../public/node/upgrade.js';
|
|
6
|
-
import { initDemoRecorder } from '../../../private/node/demo-recorder.js';
|
|
7
6
|
import { runAtMinimumInterval } from '../../../private/node/conf-store.js';
|
|
8
7
|
// This hook is called before each command run. More info: https://oclif.io/docs/hooks
|
|
9
8
|
export const hook = async (options) => {
|
|
10
|
-
initDemoRecorder();
|
|
11
9
|
const commandContent = parseCommandContent({
|
|
12
10
|
id: options.Command.id,
|
|
13
11
|
aliases: options.Command.aliases,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAC,kBAAkB,EAAE,wBAAwB,EAAC,MAAM,4BAA4B,CAAA;AACvF,OAAO,EAAC,cAAc,EAAC,MAAM,oCAAoC,CAAA;AACjE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAC,0BAA0B,EAAC,MAAM,iCAAiC,CAAA;AAE1E,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAC,kBAAkB,EAAE,wBAAwB,EAAC,MAAM,4BAA4B,CAAA;AACvF,OAAO,EAAC,cAAc,EAAC,MAAM,oCAAoC,CAAA;AACjE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAC,0BAA0B,EAAC,MAAM,iCAA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IAAI,EAAE,CAAC,EAAC,EAAE,KAAK,IAAI,EAAE;QAC5E,MAAM,YAAY,GAAG,wBAAwB,CAAC,aAAa,EAAE,cAAc,CAAC,CAAA;QAC5E,IAAI,YAAY,EAAE;YAChB,UAAU,CAAC,0BAA0B,CAAC,YAAY,CAAC,CAAC,CAAA;SACrD;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {CLI_KIT_VERSION} from '../../common/version.js'\nimport {checkForNewVersion, checkForCachedNewVersion} from '../node-package-manager.js'\nimport {startAnalytics} from '../../../private/node/analytics.js'\nimport {outputDebug, outputWarn} from '../../../public/node/output.js'\nimport {getOutputUpdateCLIReminder} from '../../../public/node/upgrade.js'\nimport Command from '../../../public/node/base-command.js'\nimport {runAtMinimumInterval} from '../../../private/node/conf-store.js'\nimport {Hook} from '@oclif/core'\n\nexport declare interface CommandContent {\n command: string\n topic?: string\n alias?: string\n}\n// This hook is called before each command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Prerun = async (options) => {\n const commandContent = parseCommandContent({\n id: options.Command.id,\n aliases: options.Command.aliases,\n pluginAlias: options.Command.plugin?.alias,\n })\n const args = options.argv\n await warnOnAvailableUpgrade()\n outputDebug(`Running command ${commandContent.command}`)\n await startAnalytics({commandContent, args, commandClass: options.Command as unknown as typeof Command})\n}\n\nexport function parseCommandContent(cmdInfo: {id: string; aliases: string[]; pluginAlias?: string}): CommandContent {\n let commandContent = parseCreateCommand(cmdInfo.pluginAlias)\n if (!commandContent) {\n commandContent = parseNormalCommand(cmdInfo.id, cmdInfo.aliases)\n }\n return commandContent\n}\n\nfunction parseNormalCommand(id: string, aliases: string[]): CommandContent {\n return {\n command: id.replace(/:/g, ' '),\n topic: parseTopic(id),\n alias: findAlias(aliases),\n }\n}\n\n/**\n * Create commands implement Init by default, so the name of the command must be extracted from\n * the plugin/module name. Neither alias or topic are supported\n *\n * @param commandClass - Oclif command configuration\n * @returns Command content with the name of the command or undefined otherwise\n */\nfunction parseCreateCommand(pluginAlias?: string): CommandContent | undefined {\n if (!pluginAlias?.startsWith('@shopify/create-')) {\n return undefined\n }\n\n return {command: pluginAlias.substring(pluginAlias.indexOf('/') + 1)}\n}\n\n/**\n * Commands use this pattern topic:subtopic1:...:subtopicN:command. This method extract the topic and subtopic\n * information replacing the ':' separator with one space\n *\n * @param cmd - Complete command string to extract the topic information\n * @returns The topic name or undefined otherwise\n */\nfunction parseTopic(cmd: string) {\n if (cmd.lastIndexOf(':') === -1) {\n return\n }\n return cmd.slice(0, cmd.lastIndexOf(':')).replace(/:/g, ' ')\n}\n\n/**\n * Identifies if the command was launched using an alias instead of the oficial command name\n *\n * @param aliases - List of possible alias a command has\n * @returns The alias used or undefined otherwise\n */\nfunction findAlias(aliases: string[]) {\n const existingAlias = aliases.find((alias) =>\n alias.split(':').every((aliasToken) => process.argv.includes(aliasToken)),\n )\n if (existingAlias) {\n return existingAlias.replace(/:/g, ' ')\n }\n}\n\n/**\n * Warns the user if there is a new version of the CLI available\n */\nexport async function warnOnAvailableUpgrade(): Promise<void> {\n const cliDependency = '@shopify/cli'\n const currentVersion = CLI_KIT_VERSION\n if (currentVersion.startsWith('0.0.0')) {\n // This is a nightly/snapshot/experimental version, so we don't want to check for updates\n return\n }\n\n // Check in the background, once daily\n // eslint-disable-next-line no-void\n void checkForNewVersion(cliDependency, currentVersion, {cacheExpiryInHours: 24})\n\n // Warn if we previously found a new version\n await runAtMinimumInterval('warn-on-available-upgrade', {days: 1}, async () => {\n const newerVersion = checkForCachedNewVersion(cliDependency, currentVersion)\n if (newerVersion) {\n outputWarn(getOutputUpdateCLIReminder(newerVersion))\n }\n })\n}\n"]}
|
|
@@ -34,7 +34,8 @@ export function currentProcessIsGlobal(argv = process.argv) {
|
|
|
34
34
|
*/
|
|
35
35
|
export async function isGlobalCLIInstalled() {
|
|
36
36
|
try {
|
|
37
|
-
const
|
|
37
|
+
const env = { ...process.env, SHOPIFY_CLI_NO_ANALYTICS: '1' };
|
|
38
|
+
const output = await captureOutput('shopify', ['app'], { env });
|
|
38
39
|
// Installed if `app dev` is available globally
|
|
39
40
|
return output.includes('app dev');
|
|
40
41
|
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-global.js","sourceRoot":"","sources":["../../../src/public/node/is-global.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAA;AAE7C,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,GAAG,EAAE,YAAY,EAAC,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAC,aAAa,EAAE,IAAI,EAAE,yBAAyB,EAAC,MAAM,aAAa,CAAA;AAC1E,OAAO,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAA;AAE/B,IAAI,SAA8B,CAAA;AAElC;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI;IACxD,wDAAwD;IACxD,IAAI,SAAS,KAAK,SAAS,IAAI,CAAC,UAAU,EAAE;QAAE,OAAO,SAAS,CAAA;IAE9D,mDAAmD;IACnD,MAAM,IAAI,GAAG,YAAY,EAAE,IAAI,GAAG,EAAE,CAAA;IAEpC,oFAAoF;IACpF,gEAAgE;IAChE,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAC,GAAG,EAAE,IAAI,EAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;IAEzE,6GAA6G;IAC7G,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAE5B,mEAAmE;IACnE,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAA;IAEnD,SAAS,GAAG,CAAC,OAAO,CAAA;I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CAAC;QACtC,OAAO,EAAE,gGAAgG;QACzG,OAAO,EAAE;YACP,EAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAC;YAC5B,EAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,2BAA2B,EAAC;SAClD;KACF,CAAC,CAAA;IAEF,OAAO,EAAC,OAAO,EAAE,MAAM,KAAK,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAC,CAAA;AAC7D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI;IACjE,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAA;IAEnD,mDAAmD;IACnD,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IACjC,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAA;IAC/C,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAA;IAC/C,IAAI,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAC7C,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {isUnitTest} from './context/local.js'\nimport {PackageManager} from './node-package-manager.js'\nimport {outputInfo} from './output.js'\nimport {cwd, sniffForPath} from './path.js'\nimport {captureOutput, exec, terminalSupportsPrompting} from './system.js'\nimport {renderSelectPrompt} from './ui.js'\nimport {execaSync} from 'execa'\n\nlet _isGlobal: boolean | undefined\n\n/**\n * Returns true if the current process is running in a global context.\n *\n * @param argv - The arguments passed to the process.\n * @returns `true` if the current process is running in a global context.\n */\nexport function currentProcessIsGlobal(argv = process.argv): boolean {\n // If we are running tests, we need to disable the cache\n if (_isGlobal !== undefined && !isUnitTest()) return _isGlobal\n\n // Path where the current project is (app/hydrogen)\n const path = sniffForPath() ?? cwd()\n\n // Closest parent directory to contain a package.json file or node_modules directory\n // https://docs.npmjs.com/cli/v8/commands/npm-prefix#description\n const npmPrefix = execaSync('npm', ['prefix'], {cwd: path}).stdout.trim()\n\n // From node docs: \"The second element [of the array] will be the path to the JavaScript file being executed\"\n const binDir = argv[1] ?? ''\n\n // If binDir starts with npmPrefix, then we are running a local CLI\n const isLocal = binDir.startsWith(npmPrefix.trim())\n\n _isGlobal = !isLocal\n return _isGlobal\n}\n\n/**\n * Returns true if the global CLI is installed.\n *\n * @returns `true` if the global CLI is installed.\n */\nexport async function isGlobalCLIInstalled(): Promise<boolean> {\n try {\n const env = {...process.env, SHOPIFY_CLI_NO_ANALYTICS: '1'}\n const output = await captureOutput('shopify', ['app'], {env})\n // Installed if `app dev` is available globally\n return output.includes('app dev')\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Installs the global Shopify CLI, using the provided package manager.\n *\n * @param packageManager - The package manager to use.\n */\nexport async function installGlobalShopifyCLI(packageManager: PackageManager): Promise<void> {\n const args =\n packageManager === 'yarn' ? ['global', 'add', '@shopify/cli@latest'] : ['install', '-g', '@shopify/cli@latest']\n outputInfo(`Running ${packageManager} ${args.join(' ')}...`)\n await exec(packageManager, args, {stdio: 'inherit'})\n}\n\nexport interface InstallGlobalCLIPromptResult {\n install: boolean\n alreadyInstalled: boolean\n}\n/**\n * Prompts the user to install the global CLI.\n *\n * @returns `true` if the user has installed the global CLI.\n */\nexport async function installGlobalCLIPrompt(): Promise<InstallGlobalCLIPromptResult> {\n if (!terminalSupportsPrompting()) return {install: false, alreadyInstalled: false}\n if (await isGlobalCLIInstalled()) {\n return {install: false, alreadyInstalled: true}\n }\n const result = await renderSelectPrompt({\n message: 'We recommend installing Shopify CLI globally in your system. Would you like to install it now?',\n choices: [\n {value: 'yes', label: 'Yes'},\n {value: 'no', label: 'No, just for this project'},\n ],\n })\n\n return {install: result === 'yes', alreadyInstalled: false}\n}\n\n/**\n * Infers the package manager used by the global CLI.\n *\n * @param argv - The arguments passed to the process.\n * @returns The package manager used by the global CLI.\n */\nexport function inferPackageManagerForGlobalCLI(argv = process.argv): PackageManager {\n if (!currentProcessIsGlobal(argv)) return 'unknown'\n\n // argv[1] contains the path of the executed binary\n const processArgv = argv[1] ?? ''\n if (processArgv.includes('yarn')) return 'yarn'\n if (processArgv.includes('pnpm')) return 'pnpm'\n if (processArgv.includes('bun')) return 'bun'\n return 'npm'\n}\n"]}
|
|
@@ -19,9 +19,10 @@ export declare function normaliseJsonSchema(schema: string): Promise<SchemaObjec
|
|
|
19
19
|
*
|
|
20
20
|
* @param subject - The object to validate.
|
|
21
21
|
* @param schema - The JSON schema to validate against.
|
|
22
|
+
* @param identifier - The identifier of the schema being validated, used to cache the validator.
|
|
22
23
|
* @returns The result of the validation. If the state is 'error', the errors will be in a zod-like format.
|
|
23
24
|
*/
|
|
24
|
-
export declare function jsonSchemaValidate(subject: object, schema: SchemaObject): ParseConfigurationResult<unknown> & {
|
|
25
|
+
export declare function jsonSchemaValidate(subject: object, schema: SchemaObject, identifier: string): ParseConfigurationResult<unknown> & {
|
|
25
26
|
rawErrors?: AjvError[];
|
|
26
27
|
};
|
|
27
28
|
export {};
|
|
@@ -16,6 +16,7 @@ export async function normaliseJsonSchema(schema) {
|
|
|
16
16
|
await $RefParser.dereference(parsedSchema, { resolve: { external: false } });
|
|
17
17
|
return parsedSchema;
|
|
18
18
|
}
|
|
19
|
+
const validatorsCache = new Map();
|
|
19
20
|
/**
|
|
20
21
|
* Given a subject object and a JSON schema contract, validate the subject against the contract.
|
|
21
22
|
*
|
|
@@ -23,11 +24,14 @@ export async function normaliseJsonSchema(schema) {
|
|
|
23
24
|
*
|
|
24
25
|
* @param subject - The object to validate.
|
|
25
26
|
* @param schema - The JSON schema to validate against.
|
|
27
|
+
* @param identifier - The identifier of the schema being validated, used to cache the validator.
|
|
26
28
|
* @returns The result of the validation. If the state is 'error', the errors will be in a zod-like format.
|
|
27
29
|
*/
|
|
28
|
-
export function jsonSchemaValidate(subject, schema) {
|
|
30
|
+
export function jsonSchemaValidate(subject, schema, identifier) {
|
|
29
31
|
const ajv = new Ajv({ allowUnionTypes: true });
|
|
30
|
-
|
|
32
|
+
ajv.addKeyword('x-taplo');
|
|
33
|
+
const validator = validatorsCache.get(identifier) ?? ajv.compile(schema);
|
|
34
|
+
validatorsCache.set(identifier, validator);
|
|
31
35
|
validator(subject);
|
|
32
36
|
// Errors from the contract are post-processed to be more zod-like and to deal with unions better
|
|
33
37
|
let jsonSchemaErrors;
|
|
@@ -133,7 +137,8 @@ function convertJsonSchemaErrors(rawErrors, subject, schema) {
|
|
|
133
137
|
* @returns A simplified list of errors.
|
|
134
138
|
*/
|
|
135
139
|
function simplifyUnionErrors(rawErrors, subject, schema) {
|
|
136
|
-
const ajv = new Ajv();
|
|
140
|
+
const ajv = new Ajv({ allowUnionTypes: true });
|
|
141
|
+
ajv.addKeyword('x-taplo');
|
|
137
142
|
let errors = rawErrors;
|
|
138
143
|
const resolvedUnionErrors = new Set();
|
|
139
144
|
while (true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../../../src/public/node/json-schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAC,GAAG,EAA4B,MAAM,KAAK,CAAA;AAClD,OAAO,UAAU,MAAM,qCAAqC,CAAA;AAI5D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAc;IACtD,0FAA0F;IAC1F,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACvC,MAAM,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,EAAC,OAAO,EAAE,EAAC,QAAQ,EAAE,KAAK,EAAC,EAAC,CAAC,CAAA;IACxE,OAAO,YAAY,CAAA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ript-eslint/no-non-null-assertion */\nimport {ParseConfigurationResult} from './schema.js'\nimport {getPathValue} from '../common/object.js'\nimport {capitalize} from '../common/string.js'\nimport {Ajv, ErrorObject, SchemaObject} from 'ajv'\nimport $RefParser from '@apidevtools/json-schema-ref-parser'\n\ntype AjvError = ErrorObject<string, {[key: string]: unknown}>\n\n/**\n * Normalises a JSON Schema by standardising it's internal implementation.\n *\n * We prefer to not use $ref elements in our schemas, so we inline them; it's easier then to process errors.\n *\n * @param schema - The JSON schema (as a string) to normalise.\n * @returns The normalised JSON schema.\n */\nexport async function normaliseJsonSchema(schema: string): Promise<SchemaObject> {\n // we want to modify the schema, removing any $ref elements and inlining with their source\n const parsedSchema = JSON.parse(schema)\n await $RefParser.dereference(parsedSchema, {resolve: {external: false}})\n return parsedSchema\n}\n\n/**\n * Given a subject object and a JSON schema contract, validate the subject against the contract.\n *\n * Errors are returned in a zod-like format, and processed to better handle unions.\n *\n * @param subject - The object to validate.\n * @param schema - The JSON schema to validate against.\n * @returns The result of the validation. If the state is 'error', the errors will be in a zod-like format.\n */\nexport function jsonSchemaValidate(\n subject: object,\n schema: SchemaObject,\n): ParseConfigurationResult<unknown> & {rawErrors?: AjvError[]} {\n const ajv = new Ajv({allowUnionTypes: true})\n const validator = ajv.compile(schema)\n validator(subject)\n\n // Errors from the contract are post-processed to be more zod-like and to deal with unions better\n let jsonSchemaErrors\n if (validator.errors && validator.errors.length > 0) {\n jsonSchemaErrors = convertJsonSchemaErrors(validator.errors, subject, schema)\n return {\n state: 'error',\n data: undefined,\n errors: jsonSchemaErrors,\n rawErrors: validator.errors,\n }\n }\n return {\n state: 'ok',\n data: subject,\n errors: undefined,\n rawErrors: undefined,\n }\n}\n\n/**\n * Converts errors from Ajv into a zod-like format.\n *\n * @param rawErrors - JSON Schema errors taken directly from Ajv.\n * @param subject - The object being validated.\n * @param schema - The JSON schema to validated against.\n * @returns The errors in a zod-like format.\n */\nfunction convertJsonSchemaErrors(rawErrors: AjvError[], subject: object, schema: SchemaObject) {\n // This reduces the number of errors by simplifying errors coming from different branches of a union\n const errors = simplifyUnionErrors(rawErrors, subject, schema)\n\n // Now we can remap errors to be more zod-like\n return errors.map((error) => {\n const path: string[] = error.instancePath.split('/').slice(1)\n if (error.params.missingProperty) {\n const missingProperty = error.params.missingProperty as string\n return {path: [...path, missingProperty], message: 'Required'}\n }\n\n if (error.params.type) {\n const expectedType = error.params.type as string\n const actualType = getPathValue(subject, path.join('.'))\n return {path, message: `Expected ${expectedType}, received ${typeof actualType}`}\n }\n\n if (error.keyword === 'anyOf' || error.keyword === 'oneOf') {\n return {path, message: 'Invalid input'}\n }\n\n if (error.params.allowedValues) {\n const allowedValues = error.params.allowedValues as string[]\n const actualValue = getPathValue(subject, path.join('.'))\n return {\n path,\n message: `Invalid enum value. Expected ${allowedValues\n .map((value) => JSON.stringify(value))\n .join(' | ')}, received ${JSON.stringify(actualValue)}`.replace(/\"/g, \"'\"),\n }\n }\n\n if (error.params.comparison) {\n const comparison = error.params.comparison as string\n const limit = error.params.limit\n const actualValue = getPathValue(subject, path.join('.'))\n\n let comparisonText = comparison\n switch (comparison) {\n case '<=':\n comparisonText = 'less than or equal to'\n break\n case '<':\n comparisonText = 'less than'\n break\n case '>=':\n comparisonText = 'greater than or equal to'\n break\n case '>':\n comparisonText = 'greater than'\n break\n }\n\n return {\n path,\n message: capitalize(`${typeof actualValue} must be ${comparisonText} ${limit}`),\n }\n }\n\n return {\n path,\n message: error.message,\n }\n })\n}\n\n/**\n * If a JSON schema specifies a union (anyOf, oneOf), and the subject doesn't meet any of the 'candidates' for the\n * union, then the error list received ends up being quite long: you get an error for the union property itself, and\n * then additional errors for each of the candidate branches.\n *\n * This function simplifies the error collection. By default it strips anything other than the union error itself.\n *\n * In some cases, it can be possible to identify what the intended branch of the union was -- for instance, maybe there\n * is a discriminating field like `type` that is unique between the branches. We inspect each candidate branch and if\n * one branch is less wrong than the others -- e.g. It had a valid `type`, but problems elsewhere -- then we keep the\n * errors for that branch.\n *\n * This is complex but in practise gives much more actionable errors.\n *\n * @param rawErrors - JSON Schema errors taken directly from Ajv.\n * @param subject - The object being validated.\n * @param schema - The JSON schema to validated against.\n * @returns A simplified list of errors.\n */\nfunction simplifyUnionErrors(rawErrors: AjvError[], subject: object, schema: SchemaObject): AjvError[] {\n const ajv = new Ajv()\n let errors = rawErrors\n\n const resolvedUnionErrors = new Set()\n while (true) {\n const unionError = errors.filter(\n (error) =>\n (error.keyword === 'oneOf' || error.keyword === 'anyOf') && !resolvedUnionErrors.has(error.instancePath),\n )[0]\n if (unionError === undefined) {\n break\n }\n // split errors into those sharing an instance path and those not\n const unrelatedErrors = errors.filter((error) => !error.instancePath.startsWith(unionError.instancePath))\n\n // we start by assuming only the union error itself is useful, and not the errors from the candidate schemas\n let simplifiedUnionRelatedErrors: AjvError[] = [unionError]\n\n // get the schema list from where the union issue occured\n const dottedSchemaPath = unionError.schemaPath.replace('#/', '').replace(/\\//g, '.')\n const unionSchemas = getPathValue<SchemaObject[]>(schema, dottedSchemaPath)\n // and the slice of the subject that caused the issue\n const subjectValue = getPathValue(subject, unionError.instancePath.split('/').slice(1).join('.'))\n\n if (unionSchemas !== undefined && subjectValue !== undefined) {\n // we know that none of the union schemas are correct, but for each of them we can measure how wrong they are\n const correctValuesAndErrors = unionSchemas\n .map((candidateSchemaFromUnion: SchemaObject) => {\n const candidateSchemaValidator = ajv.compile(candidateSchemaFromUnion)\n candidateSchemaValidator(subjectValue)\n\n let score = 0\n if (candidateSchemaFromUnion.type === 'object') {\n // provided the schema is an object, we can measure how many properties are good\n const candidatesObjectProperties = Object.keys(candidateSchemaFromUnion.properties)\n score = candidatesObjectProperties.reduce((acc, propertyName) => {\n const subSchema = candidateSchemaFromUnion.properties[propertyName] as SchemaObject\n const subjectValueSlice = getPathValue(subjectValue, propertyName)\n\n const subValidator = ajv.compile(subSchema)\n if (subValidator(subjectValueSlice)) {\n return acc + 1\n }\n return acc\n }, score)\n }\n\n return [score, candidateSchemaValidator.errors!] as const\n })\n .sort(([scoreA], [scoreB]) => scoreA - scoreB)\n\n if (correctValuesAndErrors.length >= 2) {\n const [bestScore, bestErrors] = correctValuesAndErrors[correctValuesAndErrors.length - 1]!\n const [penultimateScore] = correctValuesAndErrors[correctValuesAndErrors.length - 2]!\n\n if (bestScore !== penultimateScore) {\n // If there's a winner, show the errors for the best schema as they'll likely be actionable.\n // We got these through a nested schema, so we need to adjust the instance path\n simplifiedUnionRelatedErrors = [\n unionError,\n ...bestErrors.map((bestError) => ({\n ...bestError,\n instancePath: unionError.instancePath + bestError.instancePath,\n })),\n ]\n }\n }\n }\n errors = [...unrelatedErrors, ...simplifiedUnionRelatedErrors]\n\n resolvedUnionErrors.add(unionError.instancePath)\n }\n return errors\n}\n"]}
|
|
1
|
+
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../../../src/public/node/json-schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAC,GAAG,EAA8C,MAAM,KAAK,CAAA;AACpE,OAAO,UAAU,MAAM,qCAAqC,CAAA;AAI5D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAc;IACtD,0FAA0F;IAC1F,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACvC,MAAM,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,EAAC,OAAO,EAAE,EAAC,QAAQ,EAAE,KAAK,EAAC,EAAC,CAAC,CAAA;IACxE,OAAO,YAAY,CAAA;AACrB,CAAC;AAED,MAAM,eAAe,GAAG,IAAI,GAAG,EAA4B,CAAA;AAE3D;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAe,EACf,MAAoB,EACpB,UAAkB;IAElB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAC,eAAe,E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,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;KACjD;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport {ParseConfigurationResult} from './schema.js'\nimport {getPathValue} from '../common/object.js'\nimport {capitalize} from '../common/string.js'\nimport {Ajv, ErrorObject, SchemaObject, ValidateFunction} from 'ajv'\nimport $RefParser from '@apidevtools/json-schema-ref-parser'\n\ntype AjvError = ErrorObject<string, {[key: string]: unknown}>\n\n/**\n * Normalises a JSON Schema by standardising it's internal implementation.\n *\n * We prefer to not use $ref elements in our schemas, so we inline them; it's easier then to process errors.\n *\n * @param schema - The JSON schema (as a string) to normalise.\n * @returns The normalised JSON schema.\n */\nexport async function normaliseJsonSchema(schema: string): Promise<SchemaObject> {\n // we want to modify the schema, removing any $ref elements and inlining with their source\n const parsedSchema = JSON.parse(schema)\n await $RefParser.dereference(parsedSchema, {resolve: {external: false}})\n return parsedSchema\n}\n\nconst validatorsCache = new Map<string, ValidateFunction>()\n\n/**\n * Given a subject object and a JSON schema contract, validate the subject against the contract.\n *\n * Errors are returned in a zod-like format, and processed to better handle unions.\n *\n * @param subject - The object to validate.\n * @param schema - The JSON schema to validate against.\n * @param identifier - The identifier of the schema being validated, used to cache the validator.\n * @returns The result of the validation. If the state is 'error', the errors will be in a zod-like format.\n */\nexport function jsonSchemaValidate(\n subject: object,\n schema: SchemaObject,\n identifier: string,\n): ParseConfigurationResult<unknown> & {rawErrors?: AjvError[]} {\n const ajv = new Ajv({allowUnionTypes: true})\n\n ajv.addKeyword('x-taplo')\n\n const validator = validatorsCache.get(identifier) ?? ajv.compile(schema)\n validatorsCache.set(identifier, validator)\n\n validator(subject)\n\n // Errors from the contract are post-processed to be more zod-like and to deal with unions better\n let jsonSchemaErrors\n if (validator.errors && validator.errors.length > 0) {\n jsonSchemaErrors = convertJsonSchemaErrors(validator.errors, subject, schema)\n return {\n state: 'error',\n data: undefined,\n errors: jsonSchemaErrors,\n rawErrors: validator.errors,\n }\n }\n return {\n state: 'ok',\n data: subject,\n errors: undefined,\n rawErrors: undefined,\n }\n}\n\n/**\n * Converts errors from Ajv into a zod-like format.\n *\n * @param rawErrors - JSON Schema errors taken directly from Ajv.\n * @param subject - The object being validated.\n * @param schema - The JSON schema to validated against.\n * @returns The errors in a zod-like format.\n */\nfunction convertJsonSchemaErrors(rawErrors: AjvError[], subject: object, schema: SchemaObject) {\n // This reduces the number of errors by simplifying errors coming from different branches of a union\n const errors = simplifyUnionErrors(rawErrors, subject, schema)\n\n // Now we can remap errors to be more zod-like\n return errors.map((error) => {\n const path: string[] = error.instancePath.split('/').slice(1)\n if (error.params.missingProperty) {\n const missingProperty = error.params.missingProperty as string\n return {path: [...path, missingProperty], message: 'Required'}\n }\n\n if (error.params.type) {\n const expectedType = error.params.type as string\n const actualType = getPathValue(subject, path.join('.'))\n return {path, message: `Expected ${expectedType}, received ${typeof actualType}`}\n }\n\n if (error.keyword === 'anyOf' || error.keyword === 'oneOf') {\n return {path, message: 'Invalid input'}\n }\n\n if (error.params.allowedValues) {\n const allowedValues = error.params.allowedValues as string[]\n const actualValue = getPathValue(subject, path.join('.'))\n return {\n path,\n message: `Invalid enum value. Expected ${allowedValues\n .map((value) => JSON.stringify(value))\n .join(' | ')}, received ${JSON.stringify(actualValue)}`.replace(/\"/g, \"'\"),\n }\n }\n\n if (error.params.comparison) {\n const comparison = error.params.comparison as string\n const limit = error.params.limit\n const actualValue = getPathValue(subject, path.join('.'))\n\n let comparisonText = comparison\n switch (comparison) {\n case '<=':\n comparisonText = 'less than or equal to'\n break\n case '<':\n comparisonText = 'less than'\n break\n case '>=':\n comparisonText = 'greater than or equal to'\n break\n case '>':\n comparisonText = 'greater than'\n break\n }\n\n return {\n path,\n message: capitalize(`${typeof actualValue} must be ${comparisonText} ${limit}`),\n }\n }\n\n return {\n path,\n message: error.message,\n }\n })\n}\n\n/**\n * If a JSON schema specifies a union (anyOf, oneOf), and the subject doesn't meet any of the 'candidates' for the\n * union, then the error list received ends up being quite long: you get an error for the union property itself, and\n * then additional errors for each of the candidate branches.\n *\n * This function simplifies the error collection. By default it strips anything other than the union error itself.\n *\n * In some cases, it can be possible to identify what the intended branch of the union was -- for instance, maybe there\n * is a discriminating field like `type` that is unique between the branches. We inspect each candidate branch and if\n * one branch is less wrong than the others -- e.g. It had a valid `type`, but problems elsewhere -- then we keep the\n * errors for that branch.\n *\n * This is complex but in practise gives much more actionable errors.\n *\n * @param rawErrors - JSON Schema errors taken directly from Ajv.\n * @param subject - The object being validated.\n * @param schema - The JSON schema to validated against.\n * @returns A simplified list of errors.\n */\nfunction simplifyUnionErrors(rawErrors: AjvError[], subject: object, schema: SchemaObject): AjvError[] {\n const ajv = new Ajv({allowUnionTypes: true})\n ajv.addKeyword('x-taplo')\n let errors = rawErrors\n\n const resolvedUnionErrors = new Set()\n while (true) {\n const unionError = errors.filter(\n (error) =>\n (error.keyword === 'oneOf' || error.keyword === 'anyOf') && !resolvedUnionErrors.has(error.instancePath),\n )[0]\n if (unionError === undefined) {\n break\n }\n // split errors into those sharing an instance path and those not\n const unrelatedErrors = errors.filter((error) => !error.instancePath.startsWith(unionError.instancePath))\n\n // we start by assuming only the union error itself is useful, and not the errors from the candidate schemas\n let simplifiedUnionRelatedErrors: AjvError[] = [unionError]\n\n // get the schema list from where the union issue occured\n const dottedSchemaPath = unionError.schemaPath.replace('#/', '').replace(/\\//g, '.')\n const unionSchemas = getPathValue<SchemaObject[]>(schema, dottedSchemaPath)\n // and the slice of the subject that caused the issue\n const subjectValue = getPathValue(subject, unionError.instancePath.split('/').slice(1).join('.'))\n\n if (unionSchemas !== undefined && subjectValue !== undefined) {\n // we know that none of the union schemas are correct, but for each of them we can measure how wrong they are\n const correctValuesAndErrors = unionSchemas\n .map((candidateSchemaFromUnion: SchemaObject) => {\n const candidateSchemaValidator = ajv.compile(candidateSchemaFromUnion)\n candidateSchemaValidator(subjectValue)\n\n let score = 0\n if (candidateSchemaFromUnion.type === 'object') {\n // provided the schema is an object, we can measure how many properties are good\n const candidatesObjectProperties = Object.keys(candidateSchemaFromUnion.properties)\n score = candidatesObjectProperties.reduce((acc, propertyName) => {\n const subSchema = candidateSchemaFromUnion.properties[propertyName] as SchemaObject\n const subjectValueSlice = getPathValue(subjectValue, propertyName)\n\n const subValidator = ajv.compile(subSchema)\n if (subValidator(subjectValueSlice)) {\n return acc + 1\n }\n return acc\n }, score)\n }\n\n return [score, candidateSchemaValidator.errors!] as const\n })\n .sort(([scoreA], [scoreB]) => scoreA - scoreB)\n\n if (correctValuesAndErrors.length >= 2) {\n const [bestScore, bestErrors] = correctValuesAndErrors[correctValuesAndErrors.length - 1]!\n const [penultimateScore] = correctValuesAndErrors[correctValuesAndErrors.length - 2]!\n\n if (bestScore !== penultimateScore) {\n // If there's a winner, show the errors for the best schema as they'll likely be actionable.\n // We got these through a nested schema, so we need to adjust the instance path\n simplifiedUnionRelatedErrors = [\n unionError,\n ...bestErrors.map((bestError) => ({\n ...bestError,\n instancePath: unionError.instancePath + bestError.instancePath,\n })),\n ]\n }\n }\n }\n errors = [...unrelatedErrors, ...simplifiedUnionRelatedErrors]\n\n resolvedUnionErrors.add(unionError.instancePath)\n }\n return errors\n}\n"]}
|
|
@@ -230,7 +230,7 @@ export async function checkForNewVersion(dependency, currentVersion, { cacheExpi
|
|
|
230
230
|
*/
|
|
231
231
|
export function checkForCachedNewVersion(dependency, currentVersion) {
|
|
232
232
|
const cacheKey = `npm-package-${dependency}`;
|
|
233
|
-
const lastVersion = cacheRetrieve(cacheKey);
|
|
233
|
+
const lastVersion = cacheRetrieve(cacheKey)?.value;
|
|
234
234
|
if (lastVersion && new SemVer(currentVersion).compare(lastVersion) < 0) {
|
|
235
235
|
return lastVersion;
|
|
236
236
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-package-manager.js","sourceRoot":"","sources":["../../../src/public/node/node-package-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE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AAK,UAAU,0BAA0B,CAAC,IAAY;IACpD,WAAW,CAAC,aAAa,CAAA,8CAA8C,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC/F,OAAO,YAAY,CAAC,2BAA2B,CAAC,CAAC,GAAG,EAAE;QACpD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,SAAiB,EAAE,WAAwB;IAChF,WAAW,CAAC,aAAa,CAAA,wDAAwD,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAClH,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IACvD,MAAM,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACpE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,qBAAyC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG;IAC9F,IAAI,qBAAqB,IAAI,cAAc,CAAC,QAAQ,CAAC,qBAAuC,CAAC,EAAE;QAC7F,OAAO,qBAAuC,CAAA;KAC/C;IACD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAA;IAC3D,IAAI,kBAAkB,KAAK,SAAS;QAAE,OAAO,kBAAkB,CAAA;IAE/D,MAAM,oBAAoB,GAAG,+BAA+B,EAAE,CAAA;IAC9D,IAAI,oBAAoB,KAAK,SAAS;QAAE,OAAO,oBAAoB,CAAA;IAEnE,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {AbortError, BugError} from './error.js'\nimport {AbortController, AbortSignal} from './abort.js'\nimport {captureOutput, exec} from './system.js'\nimport {fileExists, readFile, writeFile, findPathUp, glob} from './fs.js'\nimport {dirname, joinPath} from './path.js'\nimport {runWithTimer} from './metadata.js'\nimport {inferPackageManagerForGlobalCLI} from './is-global.js'\nimport {outputToken, outputContent, outputDebug} from '../../public/node/output.js'\nimport {PackageVersionKey, cacheRetrieve, cacheRetrieveOrRepopulate} from '../../private/node/conf-store.js'\nimport latestVersion from 'latest-version'\nimport {SemVer, satisfies as semverSatisfies} from 'semver'\nimport type {Writable} from 'stream'\nimport type {ExecOptions} from './system.js'\n\n/** The name of the Yarn lock file */\nexport const yarnLockfile = 'yarn.lock'\n\n/** The name of the npm lock file */\nexport const npmLockfile = 'package-lock.json'\n\n/** The name of the pnpm lock file */\nexport const pnpmLockfile = 'pnpm-lock.yaml'\n\n/** The name of the bun lock file */\nexport const bunLockfile = 'bun.lockb'\n\n/** The name of the pnpm workspace file */\nexport const pnpmWorkspaceFile = 'pnpm-workspace.yaml'\n\n/** An array containing the lockfiles from all the package managers */\nexport const lockfiles: Lockfile[] = [yarnLockfile, pnpmLockfile, npmLockfile, bunLockfile]\nexport type Lockfile = 'yarn.lock' | 'package-lock.json' | 'pnpm-lock.yaml' | 'bun.lockb'\n\n/**\n * A union type that represents the type of dependencies in the package.json\n * - dev: devDependencies\n * - prod: dependencies\n * - peer: peerDependencies\n */\nexport type DependencyType = 'dev' | 'prod' | 'peer'\n\n/**\n * A union that represents the package managers available.\n */\nexport const packageManager = ['yarn', 'npm', 'pnpm', 'bun', 'unknown'] as const\nexport type PackageManager = (typeof packageManager)[number]\n\n/**\n * Returns an abort error that's thrown when the package manager can't be determined.\n * @returns An abort error.\n */\nexport class UnknownPackageManagerError extends AbortError {\n constructor() {\n super('Unknown package manager')\n }\n}\n\n/**\n * Returns an abort error that's thrown when a directory that's expected to have\n * a package.json doesn't have it.\n * @param directory - The path to the directory that should contain a package.json\n * @returns An abort error.\n */\nexport class PackageJsonNotFoundError extends AbortError {\n constructor(directory: string) {\n super(outputContent`The directory ${outputToken.path(directory)} doesn't have a package.json.`)\n }\n}\n\n/**\n * Returns a bug error that's thrown when the lookup of the package.json traversing the directory\n * hierarchy up can't find a package.json\n * @param directory - The directory from which the traverse has been done\n * @returns An abort error.\n */\nexport class FindUpAndReadPackageJsonNotFoundError extends BugError {\n constructor(directory: string) {\n super(outputContent`Couldn't find a a package.json traversing directories from ${outputToken.path(directory)}`)\n }\n}\n\n/**\n * Returns the dependency manager used to run the create workflow.\n * @param env - The environment variables of the process in which the CLI runs.\n * @returns The dependency manager\n */\nexport function packageManagerFromUserAgent(env = process.env): PackageManager {\n if (env.npm_config_user_agent?.includes('yarn')) {\n return 'yarn'\n } else if (env.npm_config_user_agent?.includes('pnpm')) {\n return 'pnpm'\n } else if (env.npm_config_user_agent?.includes('bun')) {\n return 'bun'\n } else if (env.npm_config_user_agent?.includes('npm')) {\n return 'npm'\n }\n return 'unknown'\n}\n\n/**\n * Returns the dependency manager used in a directory.\n * @param fromDirectory - The starting directory\n * @returns The dependency manager\n */\nexport async function getPackageManager(fromDirectory: string): Promise<PackageManager> {\n const directory = await captureOutput('npm', ['prefix'], {cwd: fromDirectory})\n outputDebug(outputContent`Obtaining the dependency manager in directory ${outputToken.path(directory)}...`)\n const packageJson = joinPath(directory, 'package.json')\n if (!(await fileExists(packageJson))) {\n return packageManagerFromUserAgent()\n }\n const yarnLockPath = joinPath(directory, yarnLockfile)\n const pnpmLockPath = joinPath(directory, pnpmLockfile)\n const bunLockPath = joinPath(directory, bunLockfile)\n if (await fileExists(yarnLockPath)) {\n return 'yarn'\n } else if (await fileExists(pnpmLockPath)) {\n return 'pnpm'\n } else if (await fileExists(bunLockPath)) {\n return 'bun'\n } else {\n return 'npm'\n }\n}\n\ninterface InstallNPMDependenciesRecursivelyOptions {\n /**\n * The dependency manager to use to install the dependencies.\n */\n packageManager: PackageManager\n /**\n * The directory from where we'll find package.json's recursively\n */\n directory: string\n\n /**\n * Specifies the maximum depth of the glob search.\n */\n deep?: number\n}\n\n/**\n * This function traverses down a directory tree to find directories containing a package.json\n * and installs the dependencies if needed. To know if it's needed, it uses the \"check\" command\n * provided by dependency managers.\n * @param options - Options to install dependencies recursively.\n */\nexport async function installNPMDependenciesRecursively(\n options: InstallNPMDependenciesRecursivelyOptions,\n): Promise<void> {\n const packageJsons = await glob(joinPath(options.directory, '**/package.json'), {\n ignore: [joinPath(options.directory, 'node_modules/**/package.json')],\n cwd: options.directory,\n onlyFiles: true,\n deep: options.deep,\n })\n const abortController = new AbortController()\n try {\n await Promise.all(\n packageJsons.map(async (packageJsonPath) => {\n const directory = dirname(packageJsonPath)\n await installNodeModules({\n directory,\n packageManager: options.packageManager,\n stdout: undefined,\n stderr: undefined,\n signal: abortController.signal,\n args: [],\n })\n }),\n )\n } catch (error) {\n abortController.abort()\n throw error\n }\n}\n\ninterface InstallNodeModulesOptions {\n directory: string\n args?: string[]\n packageManager: PackageManager\n stdout?: Writable\n stderr?: Writable\n signal?: AbortSignal\n}\n\nexport async function installNodeModules(options: InstallNodeModulesOptions): Promise<void> {\n const execOptions: ExecOptions = {\n cwd: options.directory,\n stdin: undefined,\n stdout: options.stdout,\n stderr: options.stderr,\n signal: options.signal,\n }\n let args = ['install']\n if (options.args) {\n args = args.concat(options.args)\n }\n await runWithTimer('cmd_all_timing_network_ms')(async () => {\n await exec(options.packageManager, args, execOptions)\n })\n}\n\n/**\n * Returns the name of the package configured in its package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the name.\n */\nexport async function getPackageName(packageJsonPath: string): Promise<string | undefined> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n return packageJsonContent.name\n}\n/**\n * Returns the version of the package configured in its package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the version.\n */\nexport async function getPackageVersion(packageJsonPath: string): Promise<string | undefined> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n return packageJsonContent.version\n}\n\n/**\n * Returns the list of production and dev dependencies of a package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the list of dependencies.\n */\nexport async function getDependencies(packageJsonPath: string): Promise<{[key: string]: string}> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n const dependencies: {[key: string]: string} = packageJsonContent.dependencies ?? {}\n const devDependencies: {[key: string]: string} = packageJsonContent.devDependencies ?? {}\n\n return {...dependencies, ...devDependencies}\n}\n\n/**\n * Returns true if the app uses workspaces, false otherwise.\n * @param packageJsonPath - Path to the package.json file\n * @param pnpmWorkspacePath - Path to the pnpm-workspace.yaml file\n * @returns A promise that resolves with true if the app uses workspaces, false otherwise.\n */\nexport async function usesWorkspaces(appDirectory: string): Promise<boolean> {\n const packageJsonPath = joinPath(appDirectory, 'package.json')\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n const pnpmWorkspacePath = joinPath(appDirectory, pnpmWorkspaceFile)\n return Boolean(packageJsonContent.workspaces) || fileExists(pnpmWorkspacePath)\n}\n\n/**\n * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.\n * @param dependency - The dependency name (e.g. react)\n * @param currentVersion - The current version.\n * @param cacheExpiryInHours - If the last check was done more than this amount of hours ago, it will\n * refresh the cache. Defaults to always refreshing.\n * @returns A promise that resolves with a more recent version or undefined if there's no more recent version.\n */\nexport async function checkForNewVersion(\n dependency: string,\n currentVersion: string,\n {cacheExpiryInHours = 0} = {},\n): Promise<string | undefined> {\n const getLatestVersion = async () => {\n outputDebug(outputContent`Checking if there's a version of ${dependency} newer than ${currentVersion}`)\n return getLatestNPMPackageVersion(dependency)\n }\n\n const cacheKey: PackageVersionKey = `npm-package-${dependency}`\n let lastVersion\n try {\n lastVersion = await cacheRetrieveOrRepopulate(cacheKey, getLatestVersion, cacheExpiryInHours * 3600 * 1000)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n return undefined\n }\n\n if (lastVersion && new SemVer(currentVersion).compare(lastVersion) < 0) {\n return lastVersion\n } else {\n return undefined\n }\n}\n\n/**\n * Given an NPM dependency, it checks if there's a cached more recent version, and if there is, it returns its value.\n * @param dependency - The dependency name (e.g. react)\n * @param currentVersion - The current version.\n * @returns A more recent version or undefined if there's no more recent version.\n */\nexport function checkForCachedNewVersion(dependency: string, currentVersion: string): string | undefined {\n const cacheKey: PackageVersionKey = `npm-package-${dependency}`\n const lastVersion = cacheRetrieve(cacheKey)\n\n if (lastVersion && new SemVer(currentVersion).compare(lastVersion) < 0) {\n return lastVersion\n } else {\n return undefined\n }\n}\n\n/**\n * Utility function used to check whether a package version satisfies some requirements\n * @param version - The version to check\n * @param requirements - The requirements to check against, e.g. \"\\>=1.0.0\" - see https://www.npmjs.com/package/semver#ranges\n * @returns A boolean indicating whether the version satisfies the requirements\n */\nexport function versionSatisfies(version: string, requirements: string): boolean {\n return semverSatisfies(version, requirements)\n}\n\n/**\n * An interface that represents a package.json\n */\nexport interface PackageJson {\n /**\n * The name attribute of the package.json\n */\n name?: string\n\n /**\n * The author attribute of the package.json\n */\n author?: string\n\n /**\n * The version attribute of the package.json\n */\n version?: string\n\n /**\n * The scripts attribute of the package.json\n */\n scripts?: {[key: string]: string}\n\n /**\n * The dependencies attribute of the package.json\n */\n dependencies?: {[key: string]: string}\n\n /**\n * The devDependencies attribute of the package.json\n */\n devDependencies?: {[key: string]: string}\n\n /**\n * The peerDependencies attribute of the package.json\n */\n peerDependencies?: {[key: string]: string}\n\n /**\n * The optional oclif settings attribute of the package.json\n */\n oclif?: {\n plugins?: string[]\n }\n\n /**\n * The workspaces attribute of the package.json\n */\n workspaces?: string[]\n\n /**\n * The resolutions attribute of the package.json. Only useful when using yarn as package manager\n */\n resolutions?: {[key: string]: string}\n\n /**\n * The overrides attribute of the package.json. Only useful when using npm o npmn as package managers\n */\n overrides?: {[key: string]: string}\n\n /**\n * The prettier attribute of the package.json\n */\n prettier?: string\n\n /**\n * The private attribute of the package.json.\n * https://docs.npmjs.com/cli/v9/configuring-npm/package-json#private\n */\n private?: boolean\n}\n\n/**\n * Reads and parses a package.json\n * @param packageJsonPath - Path to the package.json\n * @returns An promise that resolves with an in-memory representation\n * of the package.json or rejects with an error if the file is not found or the content is\n * not decodable.\n */\nexport async function readAndParsePackageJson(packageJsonPath: string): Promise<PackageJson> {\n if (!(await fileExists(packageJsonPath))) {\n throw new PackageJsonNotFoundError(dirname(packageJsonPath))\n }\n return JSON.parse(await readFile(packageJsonPath))\n}\n\ninterface AddNPMDependenciesIfNeededOptions {\n /** How dependencies should be added */\n type: DependencyType\n\n /** The dependency manager to use to add dependencies */\n packageManager: PackageManager\n\n /** The directory that contains the package.json where dependencies will be added */\n directory: string\n\n /** Standard output coming from the underlying installation process */\n stdout?: Writable\n\n /** Standard error coming from the underlying installation process */\n stderr?: Writable\n\n /** Abort signal to stop the process */\n signal?: AbortSignal\n\n /** Whether to add the dependencies to the root package.json or to the package.json of the directory */\n addToRootDirectory?: boolean\n}\n\n/**\n * An interface that represents a dependency name with its version\n */\nexport interface DependencyVersion {\n /**\n * The name of the NPM dependency as it's reflected in the package.json:\n *\n * @example\n * In the example below name would be \"react\"\n * ```\n * {\n * \"react\": \"1.2.3\"\n * }\n * ```\n */\n name: string\n\n /**\n * The version of the NPM dependency as it's reflected in the package.json:\n *\n * @example\n * In the example below version would be \"1.2.3\"\n * ```\n * {\n * \"react\": \"1.2.3\"\n * }\n * ```\n */\n version: string | undefined\n}\n\n/**\n * Adds dependencies to a Node project (i.e. a project that has a package.json)\n * @param dependencies - List of dependencies to be added.\n * @param options - Options for adding dependencies.\n */\nexport async function addNPMDependenciesIfNeeded(\n dependencies: DependencyVersion[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n outputDebug(outputContent`Adding the following dependencies if needed:\n${outputToken.json(dependencies)}\nWith options:\n${outputToken.json(options)}\n `)\n const packageJsonPath = joinPath(options.directory, 'package.json')\n if (!(await fileExists(packageJsonPath))) {\n throw new PackageJsonNotFoundError(options.directory)\n }\n const existingDependencies = Object.keys(await getDependencies(packageJsonPath))\n const dependenciesToAdd = dependencies.filter((dep) => {\n return !existingDependencies.includes(dep.name)\n })\n if (dependenciesToAdd.length === 0) {\n return\n }\n await addNPMDependencies(dependenciesToAdd, options)\n}\n\nexport async function addNPMDependencies(\n dependencies: DependencyVersion[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n const dependenciesWithVersion = dependencies.map((dep) => {\n return dep.version ? `${dep.name}@${dep.version}` : dep.name\n })\n options.stdout?.write(`Installing ${[dependenciesWithVersion].join(' ')} with ${options.packageManager}`)\n switch (options.packageManager) {\n case 'npm':\n // npm isn't too smart when resolving the dependency tree. For example, admin ui extensions include react as\n // a peer dependency, but npm can't figure out the relationship and fails. Installing dependencies one by one\n // makes the task easier and npm can then proceed.\n for (const dep of dependenciesWithVersion) {\n // eslint-disable-next-line no-await-in-loop\n await installDependencies(options, argumentsToAddDependenciesWithNPM(dep, options.type))\n }\n break\n case 'yarn':\n await installDependencies(\n options,\n argumentsToAddDependenciesWithYarn(dependenciesWithVersion, options.type, Boolean(options.addToRootDirectory)),\n )\n break\n case 'pnpm':\n await installDependencies(\n options,\n argumentsToAddDependenciesWithPNPM(dependenciesWithVersion, options.type, Boolean(options.addToRootDirectory)),\n )\n break\n case 'bun':\n await installDependencies(options, argumentsToAddDependenciesWithBun(dependenciesWithVersion, options.type))\n await installDependencies(options, ['install'])\n break\n case 'unknown':\n throw new UnknownPackageManagerError()\n }\n}\n\nasync function installDependencies(options: AddNPMDependenciesIfNeededOptions, args: string[]) {\n return runWithTimer('cmd_all_timing_network_ms')(async () => {\n return exec(options.packageManager, args, {\n cwd: options.directory,\n stdout: options.stdout,\n stderr: options.stderr,\n signal: options.signal,\n })\n })\n}\n\nexport async function addNPMDependenciesWithoutVersionIfNeeded(\n dependencies: string[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n await addNPMDependenciesIfNeeded(\n dependencies.map((dependency) => {\n return {name: dependency, version: undefined}\n }),\n options,\n )\n}\n\n/**\n * Returns the arguments to add dependencies using NPM.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithNPM(dependency: string, type: DependencyType): string[] {\n let command = ['install']\n command = command.concat(dependency)\n switch (type) {\n case 'dev':\n command.push('--save-dev')\n break\n case 'peer':\n command.push('--save-peer')\n break\n case 'prod':\n command.push('--save-prod')\n break\n }\n // NPM adds ^ to the installed version by default. We want to install exact versions unless specified otherwise.\n if (dependency.match(/@\\d/g)) {\n command.push('--save-exact')\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using Yarn.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @param addAtRoot - Force to install the dependencies in the workspace root (optional, default = false)\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithYarn(dependencies: string[], type: DependencyType, addAtRoot = false): string[] {\n let command = ['add']\n\n if (addAtRoot) {\n command.push('-W')\n }\n\n command = command.concat(dependencies)\n switch (type) {\n case 'dev':\n command.push('--dev')\n break\n case 'peer':\n command.push('--peer')\n break\n case 'prod':\n command.push('--prod')\n break\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using PNPM.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @param addAtRoot - Force to install the dependencies in the workspace root (optional, default = false)\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithPNPM(dependencies: string[], type: DependencyType, addAtRoot = false): string[] {\n let command = ['add']\n\n if (addAtRoot) {\n command.push('-w')\n }\n\n command = command.concat(dependencies)\n\n switch (type) {\n case 'dev':\n command.push('--save-dev')\n break\n case 'peer':\n command.push('--save-peer')\n break\n case 'prod':\n command.push('--save-prod')\n break\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using Bun.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithBun(dependencies: string[], type: DependencyType): string[] {\n let command = ['add']\n\n command = command.concat(dependencies)\n\n switch (type) {\n case 'dev':\n command.push('--development')\n break\n case 'peer':\n command.push('--optional')\n break\n case 'prod':\n break\n }\n return command\n}\n\n/**\n * Given a directory it traverses the directory up looking for a package.json and if found, it reads it\n * decodes the JSON, and returns its content as a Javascript object.\n * @param options - The directory from which traverse up.\n * @returns If found, the promise resolves with the path to the\n * package.json and its content. If not found, it throws a FindUpAndReadPackageJsonNotFoundError error.\n */\nexport async function findUpAndReadPackageJson(fromDirectory: string): Promise<{path: string; content: PackageJson}> {\n const packageJsonPath = await findPathUp('package.json', {cwd: fromDirectory, type: 'file'})\n if (packageJsonPath) {\n const packageJson = JSON.parse(await readFile(packageJsonPath))\n return {path: packageJsonPath, content: packageJson}\n } else {\n throw new FindUpAndReadPackageJsonNotFoundError(fromDirectory)\n }\n}\n\nexport async function addResolutionOrOverride(directory: string, dependencies: {[key: string]: string}): Promise<void> {\n const packageManager = await getPackageManager(directory)\n const packageJsonPath = joinPath(directory, 'package.json')\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n\n if (packageManager === 'yarn') {\n packageJsonContent.resolutions = packageJsonContent.resolutions\n ? {...packageJsonContent.resolutions, ...dependencies}\n : dependencies\n }\n if (packageManager === 'npm' || packageManager === 'pnpm' || packageManager === 'bun') {\n packageJsonContent.overrides = packageJsonContent.overrides\n ? {...packageJsonContent.overrides, ...dependencies}\n : dependencies\n }\n\n await writeFile(packageJsonPath, JSON.stringify(packageJsonContent, null, 2))\n}\n\n/**\n * Returns the latest available version of an NPM package.\n * @param name - The name of the NPM package.\n * @returns A promise to get the latest available version of a package.\n */\nasync function getLatestNPMPackageVersion(name: string) {\n outputDebug(outputContent`Getting the latest version of NPM package: ${outputToken.raw(name)}`)\n return runWithTimer('cmd_all_timing_network_ms')(() => {\n return latestVersion(name)\n })\n}\n\n/**\n * Writes the package.json file to the given directory.\n *\n * @param directory - Directory where the package.json file will be written.\n * @param packageJSON - Package.json file to write.\n */\nexport async function writePackageJSON(directory: string, packageJSON: PackageJson): Promise<void> {\n outputDebug(outputContent`JSON-encoding and writing content to package.json at ${outputToken.path(directory)}...`)\n const packagePath = joinPath(directory, 'package.json')\n await writeFile(packagePath, JSON.stringify(packageJSON, null, 2))\n}\n\n/**\n * Infers the package manager to be used based on the provided options and environment.\n *\n * This function determines the package manager in the following order of precedence:\n * 1. Uses the package manager specified in the options, if valid.\n * 2. Infers the package manager from the user agent string.\n * 3. Infers the package manager used for the global CLI installation.\n * 4. Defaults to 'npm' if no other method succeeds.\n *\n * @param optionsPackageManager - The package manager specified in the options (if any).\n * @returns The inferred package manager as a PackageManager type.\n */\nexport function inferPackageManager(optionsPackageManager: string | undefined, env = process.env): PackageManager {\n if (optionsPackageManager && packageManager.includes(optionsPackageManager as PackageManager)) {\n return optionsPackageManager as PackageManager\n }\n const usedPackageManager = packageManagerFromUserAgent(env)\n if (usedPackageManager !== 'unknown') return usedPackageManager\n\n const globalPackageManager = inferPackageManagerForGlobalCLI()\n if (globalPackageManager !== 'unknown') return globalPackageManager\n\n return 'npm'\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node-package-manager.js","sourceRoot":"","sources":["../../../src/public/node/node-package-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,eAAe,EAAc,MAAM,YAAY,CAAA;AACvD,OAAO,EAAC,aAAa,EAAE,IAAI,EAAC,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAC,MAAM,SAAS,CAAA;AACzE,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAC,+BAA+B,EAAC,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,EAAoB,aAAa,EAAE,yBAAyB,EAAC,MAAM,kCAAkC,CAAA;AAC5G,O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AC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACpE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,qBAAyC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG;IAC9F,IAAI,qBAAqB,IAAI,cAAc,CAAC,QAAQ,CAAC,qBAAuC,CAAC,EAAE;QAC7F,OAAO,qBAAuC,CAAA;KAC/C;IACD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAA;IAC3D,IAAI,kBAAkB,KAAK,SAAS;QAAE,OAAO,kBAAkB,CAAA;IAE/D,MAAM,oBAAoB,GAAG,+BAA+B,EAAE,CAAA;IAC9D,IAAI,oBAAoB,KAAK,SAAS;QAAE,OAAO,oBAAoB,CAAA;IAEnE,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {AbortError, BugError} from './error.js'\nimport {AbortController, AbortSignal} from './abort.js'\nimport {captureOutput, exec} from './system.js'\nimport {fileExists, readFile, writeFile, findPathUp, glob} from './fs.js'\nimport {dirname, joinPath} from './path.js'\nimport {runWithTimer} from './metadata.js'\nimport {inferPackageManagerForGlobalCLI} from './is-global.js'\nimport {outputToken, outputContent, outputDebug} from '../../public/node/output.js'\nimport {PackageVersionKey, cacheRetrieve, cacheRetrieveOrRepopulate} from '../../private/node/conf-store.js'\nimport latestVersion from 'latest-version'\nimport {SemVer, satisfies as semverSatisfies} from 'semver'\nimport type {Writable} from 'stream'\nimport type {ExecOptions} from './system.js'\n\n/** The name of the Yarn lock file */\nexport const yarnLockfile = 'yarn.lock'\n\n/** The name of the npm lock file */\nexport const npmLockfile = 'package-lock.json'\n\n/** The name of the pnpm lock file */\nexport const pnpmLockfile = 'pnpm-lock.yaml'\n\n/** The name of the bun lock file */\nexport const bunLockfile = 'bun.lockb'\n\n/** The name of the pnpm workspace file */\nexport const pnpmWorkspaceFile = 'pnpm-workspace.yaml'\n\n/** An array containing the lockfiles from all the package managers */\nexport const lockfiles: Lockfile[] = [yarnLockfile, pnpmLockfile, npmLockfile, bunLockfile]\nexport type Lockfile = 'yarn.lock' | 'package-lock.json' | 'pnpm-lock.yaml' | 'bun.lockb'\n\n/**\n * A union type that represents the type of dependencies in the package.json\n * - dev: devDependencies\n * - prod: dependencies\n * - peer: peerDependencies\n */\nexport type DependencyType = 'dev' | 'prod' | 'peer'\n\n/**\n * A union that represents the package managers available.\n */\nexport const packageManager = ['yarn', 'npm', 'pnpm', 'bun', 'unknown'] as const\nexport type PackageManager = (typeof packageManager)[number]\n\n/**\n * Returns an abort error that's thrown when the package manager can't be determined.\n * @returns An abort error.\n */\nexport class UnknownPackageManagerError extends AbortError {\n constructor() {\n super('Unknown package manager')\n }\n}\n\n/**\n * Returns an abort error that's thrown when a directory that's expected to have\n * a package.json doesn't have it.\n * @param directory - The path to the directory that should contain a package.json\n * @returns An abort error.\n */\nexport class PackageJsonNotFoundError extends AbortError {\n constructor(directory: string) {\n super(outputContent`The directory ${outputToken.path(directory)} doesn't have a package.json.`)\n }\n}\n\n/**\n * Returns a bug error that's thrown when the lookup of the package.json traversing the directory\n * hierarchy up can't find a package.json\n * @param directory - The directory from which the traverse has been done\n * @returns An abort error.\n */\nexport class FindUpAndReadPackageJsonNotFoundError extends BugError {\n constructor(directory: string) {\n super(outputContent`Couldn't find a a package.json traversing directories from ${outputToken.path(directory)}`)\n }\n}\n\n/**\n * Returns the dependency manager used to run the create workflow.\n * @param env - The environment variables of the process in which the CLI runs.\n * @returns The dependency manager\n */\nexport function packageManagerFromUserAgent(env = process.env): PackageManager {\n if (env.npm_config_user_agent?.includes('yarn')) {\n return 'yarn'\n } else if (env.npm_config_user_agent?.includes('pnpm')) {\n return 'pnpm'\n } else if (env.npm_config_user_agent?.includes('bun')) {\n return 'bun'\n } else if (env.npm_config_user_agent?.includes('npm')) {\n return 'npm'\n }\n return 'unknown'\n}\n\n/**\n * Returns the dependency manager used in a directory.\n * @param fromDirectory - The starting directory\n * @returns The dependency manager\n */\nexport async function getPackageManager(fromDirectory: string): Promise<PackageManager> {\n const directory = await captureOutput('npm', ['prefix'], {cwd: fromDirectory})\n outputDebug(outputContent`Obtaining the dependency manager in directory ${outputToken.path(directory)}...`)\n const packageJson = joinPath(directory, 'package.json')\n if (!(await fileExists(packageJson))) {\n return packageManagerFromUserAgent()\n }\n const yarnLockPath = joinPath(directory, yarnLockfile)\n const pnpmLockPath = joinPath(directory, pnpmLockfile)\n const bunLockPath = joinPath(directory, bunLockfile)\n if (await fileExists(yarnLockPath)) {\n return 'yarn'\n } else if (await fileExists(pnpmLockPath)) {\n return 'pnpm'\n } else if (await fileExists(bunLockPath)) {\n return 'bun'\n } else {\n return 'npm'\n }\n}\n\ninterface InstallNPMDependenciesRecursivelyOptions {\n /**\n * The dependency manager to use to install the dependencies.\n */\n packageManager: PackageManager\n /**\n * The directory from where we'll find package.json's recursively\n */\n directory: string\n\n /**\n * Specifies the maximum depth of the glob search.\n */\n deep?: number\n}\n\n/**\n * This function traverses down a directory tree to find directories containing a package.json\n * and installs the dependencies if needed. To know if it's needed, it uses the \"check\" command\n * provided by dependency managers.\n * @param options - Options to install dependencies recursively.\n */\nexport async function installNPMDependenciesRecursively(\n options: InstallNPMDependenciesRecursivelyOptions,\n): Promise<void> {\n const packageJsons = await glob(joinPath(options.directory, '**/package.json'), {\n ignore: [joinPath(options.directory, 'node_modules/**/package.json')],\n cwd: options.directory,\n onlyFiles: true,\n deep: options.deep,\n })\n const abortController = new AbortController()\n try {\n await Promise.all(\n packageJsons.map(async (packageJsonPath) => {\n const directory = dirname(packageJsonPath)\n await installNodeModules({\n directory,\n packageManager: options.packageManager,\n stdout: undefined,\n stderr: undefined,\n signal: abortController.signal,\n args: [],\n })\n }),\n )\n } catch (error) {\n abortController.abort()\n throw error\n }\n}\n\ninterface InstallNodeModulesOptions {\n directory: string\n args?: string[]\n packageManager: PackageManager\n stdout?: Writable\n stderr?: Writable\n signal?: AbortSignal\n}\n\nexport async function installNodeModules(options: InstallNodeModulesOptions): Promise<void> {\n const execOptions: ExecOptions = {\n cwd: options.directory,\n stdin: undefined,\n stdout: options.stdout,\n stderr: options.stderr,\n signal: options.signal,\n }\n let args = ['install']\n if (options.args) {\n args = args.concat(options.args)\n }\n await runWithTimer('cmd_all_timing_network_ms')(async () => {\n await exec(options.packageManager, args, execOptions)\n })\n}\n\n/**\n * Returns the name of the package configured in its package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the name.\n */\nexport async function getPackageName(packageJsonPath: string): Promise<string | undefined> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n return packageJsonContent.name\n}\n/**\n * Returns the version of the package configured in its package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the version.\n */\nexport async function getPackageVersion(packageJsonPath: string): Promise<string | undefined> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n return packageJsonContent.version\n}\n\n/**\n * Returns the list of production and dev dependencies of a package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the list of dependencies.\n */\nexport async function getDependencies(packageJsonPath: string): Promise<{[key: string]: string}> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n const dependencies: {[key: string]: string} = packageJsonContent.dependencies ?? {}\n const devDependencies: {[key: string]: string} = packageJsonContent.devDependencies ?? {}\n\n return {...dependencies, ...devDependencies}\n}\n\n/**\n * Returns true if the app uses workspaces, false otherwise.\n * @param packageJsonPath - Path to the package.json file\n * @param pnpmWorkspacePath - Path to the pnpm-workspace.yaml file\n * @returns A promise that resolves with true if the app uses workspaces, false otherwise.\n */\nexport async function usesWorkspaces(appDirectory: string): Promise<boolean> {\n const packageJsonPath = joinPath(appDirectory, 'package.json')\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n const pnpmWorkspacePath = joinPath(appDirectory, pnpmWorkspaceFile)\n return Boolean(packageJsonContent.workspaces) || fileExists(pnpmWorkspacePath)\n}\n\n/**\n * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.\n * @param dependency - The dependency name (e.g. react)\n * @param currentVersion - The current version.\n * @param cacheExpiryInHours - If the last check was done more than this amount of hours ago, it will\n * refresh the cache. Defaults to always refreshing.\n * @returns A promise that resolves with a more recent version or undefined if there's no more recent version.\n */\nexport async function checkForNewVersion(\n dependency: string,\n currentVersion: string,\n {cacheExpiryInHours = 0} = {},\n): Promise<string | undefined> {\n const getLatestVersion = async () => {\n outputDebug(outputContent`Checking if there's a version of ${dependency} newer than ${currentVersion}`)\n return getLatestNPMPackageVersion(dependency)\n }\n\n const cacheKey: PackageVersionKey = `npm-package-${dependency}`\n let lastVersion\n try {\n lastVersion = await cacheRetrieveOrRepopulate(cacheKey, getLatestVersion, cacheExpiryInHours * 3600 * 1000)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n return undefined\n }\n\n if (lastVersion && new SemVer(currentVersion).compare(lastVersion) < 0) {\n return lastVersion\n } else {\n return undefined\n }\n}\n\n/**\n * Given an NPM dependency, it checks if there's a cached more recent version, and if there is, it returns its value.\n * @param dependency - The dependency name (e.g. react)\n * @param currentVersion - The current version.\n * @returns A more recent version or undefined if there's no more recent version.\n */\nexport function checkForCachedNewVersion(dependency: string, currentVersion: string): string | undefined {\n const cacheKey: PackageVersionKey = `npm-package-${dependency}`\n const lastVersion = cacheRetrieve(cacheKey)?.value\n\n if (lastVersion && new SemVer(currentVersion).compare(lastVersion) < 0) {\n return lastVersion\n } else {\n return undefined\n }\n}\n\n/**\n * Utility function used to check whether a package version satisfies some requirements\n * @param version - The version to check\n * @param requirements - The requirements to check against, e.g. \"\\>=1.0.0\" - see https://www.npmjs.com/package/semver#ranges\n * @returns A boolean indicating whether the version satisfies the requirements\n */\nexport function versionSatisfies(version: string, requirements: string): boolean {\n return semverSatisfies(version, requirements)\n}\n\n/**\n * An interface that represents a package.json\n */\nexport interface PackageJson {\n /**\n * The name attribute of the package.json\n */\n name?: string\n\n /**\n * The author attribute of the package.json\n */\n author?: string\n\n /**\n * The version attribute of the package.json\n */\n version?: string\n\n /**\n * The scripts attribute of the package.json\n */\n scripts?: {[key: string]: string}\n\n /**\n * The dependencies attribute of the package.json\n */\n dependencies?: {[key: string]: string}\n\n /**\n * The devDependencies attribute of the package.json\n */\n devDependencies?: {[key: string]: string}\n\n /**\n * The peerDependencies attribute of the package.json\n */\n peerDependencies?: {[key: string]: string}\n\n /**\n * The optional oclif settings attribute of the package.json\n */\n oclif?: {\n plugins?: string[]\n }\n\n /**\n * The workspaces attribute of the package.json\n */\n workspaces?: string[]\n\n /**\n * The resolutions attribute of the package.json. Only useful when using yarn as package manager\n */\n resolutions?: {[key: string]: string}\n\n /**\n * The overrides attribute of the package.json. Only useful when using npm o npmn as package managers\n */\n overrides?: {[key: string]: string}\n\n /**\n * The prettier attribute of the package.json\n */\n prettier?: string\n\n /**\n * The private attribute of the package.json.\n * https://docs.npmjs.com/cli/v9/configuring-npm/package-json#private\n */\n private?: boolean\n}\n\n/**\n * Reads and parses a package.json\n * @param packageJsonPath - Path to the package.json\n * @returns An promise that resolves with an in-memory representation\n * of the package.json or rejects with an error if the file is not found or the content is\n * not decodable.\n */\nexport async function readAndParsePackageJson(packageJsonPath: string): Promise<PackageJson> {\n if (!(await fileExists(packageJsonPath))) {\n throw new PackageJsonNotFoundError(dirname(packageJsonPath))\n }\n return JSON.parse(await readFile(packageJsonPath))\n}\n\ninterface AddNPMDependenciesIfNeededOptions {\n /** How dependencies should be added */\n type: DependencyType\n\n /** The dependency manager to use to add dependencies */\n packageManager: PackageManager\n\n /** The directory that contains the package.json where dependencies will be added */\n directory: string\n\n /** Standard output coming from the underlying installation process */\n stdout?: Writable\n\n /** Standard error coming from the underlying installation process */\n stderr?: Writable\n\n /** Abort signal to stop the process */\n signal?: AbortSignal\n\n /** Whether to add the dependencies to the root package.json or to the package.json of the directory */\n addToRootDirectory?: boolean\n}\n\n/**\n * An interface that represents a dependency name with its version\n */\nexport interface DependencyVersion {\n /**\n * The name of the NPM dependency as it's reflected in the package.json:\n *\n * @example\n * In the example below name would be \"react\"\n * ```\n * {\n * \"react\": \"1.2.3\"\n * }\n * ```\n */\n name: string\n\n /**\n * The version of the NPM dependency as it's reflected in the package.json:\n *\n * @example\n * In the example below version would be \"1.2.3\"\n * ```\n * {\n * \"react\": \"1.2.3\"\n * }\n * ```\n */\n version: string | undefined\n}\n\n/**\n * Adds dependencies to a Node project (i.e. a project that has a package.json)\n * @param dependencies - List of dependencies to be added.\n * @param options - Options for adding dependencies.\n */\nexport async function addNPMDependenciesIfNeeded(\n dependencies: DependencyVersion[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n outputDebug(outputContent`Adding the following dependencies if needed:\n${outputToken.json(dependencies)}\nWith options:\n${outputToken.json(options)}\n `)\n const packageJsonPath = joinPath(options.directory, 'package.json')\n if (!(await fileExists(packageJsonPath))) {\n throw new PackageJsonNotFoundError(options.directory)\n }\n const existingDependencies = Object.keys(await getDependencies(packageJsonPath))\n const dependenciesToAdd = dependencies.filter((dep) => {\n return !existingDependencies.includes(dep.name)\n })\n if (dependenciesToAdd.length === 0) {\n return\n }\n await addNPMDependencies(dependenciesToAdd, options)\n}\n\nexport async function addNPMDependencies(\n dependencies: DependencyVersion[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n const dependenciesWithVersion = dependencies.map((dep) => {\n return dep.version ? `${dep.name}@${dep.version}` : dep.name\n })\n options.stdout?.write(`Installing ${[dependenciesWithVersion].join(' ')} with ${options.packageManager}`)\n switch (options.packageManager) {\n case 'npm':\n // npm isn't too smart when resolving the dependency tree. For example, admin ui extensions include react as\n // a peer dependency, but npm can't figure out the relationship and fails. Installing dependencies one by one\n // makes the task easier and npm can then proceed.\n for (const dep of dependenciesWithVersion) {\n // eslint-disable-next-line no-await-in-loop\n await installDependencies(options, argumentsToAddDependenciesWithNPM(dep, options.type))\n }\n break\n case 'yarn':\n await installDependencies(\n options,\n argumentsToAddDependenciesWithYarn(dependenciesWithVersion, options.type, Boolean(options.addToRootDirectory)),\n )\n break\n case 'pnpm':\n await installDependencies(\n options,\n argumentsToAddDependenciesWithPNPM(dependenciesWithVersion, options.type, Boolean(options.addToRootDirectory)),\n )\n break\n case 'bun':\n await installDependencies(options, argumentsToAddDependenciesWithBun(dependenciesWithVersion, options.type))\n await installDependencies(options, ['install'])\n break\n case 'unknown':\n throw new UnknownPackageManagerError()\n }\n}\n\nasync function installDependencies(options: AddNPMDependenciesIfNeededOptions, args: string[]) {\n return runWithTimer('cmd_all_timing_network_ms')(async () => {\n return exec(options.packageManager, args, {\n cwd: options.directory,\n stdout: options.stdout,\n stderr: options.stderr,\n signal: options.signal,\n })\n })\n}\n\nexport async function addNPMDependenciesWithoutVersionIfNeeded(\n dependencies: string[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n await addNPMDependenciesIfNeeded(\n dependencies.map((dependency) => {\n return {name: dependency, version: undefined}\n }),\n options,\n )\n}\n\n/**\n * Returns the arguments to add dependencies using NPM.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithNPM(dependency: string, type: DependencyType): string[] {\n let command = ['install']\n command = command.concat(dependency)\n switch (type) {\n case 'dev':\n command.push('--save-dev')\n break\n case 'peer':\n command.push('--save-peer')\n break\n case 'prod':\n command.push('--save-prod')\n break\n }\n // NPM adds ^ to the installed version by default. We want to install exact versions unless specified otherwise.\n if (dependency.match(/@\\d/g)) {\n command.push('--save-exact')\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using Yarn.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @param addAtRoot - Force to install the dependencies in the workspace root (optional, default = false)\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithYarn(dependencies: string[], type: DependencyType, addAtRoot = false): string[] {\n let command = ['add']\n\n if (addAtRoot) {\n command.push('-W')\n }\n\n command = command.concat(dependencies)\n switch (type) {\n case 'dev':\n command.push('--dev')\n break\n case 'peer':\n command.push('--peer')\n break\n case 'prod':\n command.push('--prod')\n break\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using PNPM.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @param addAtRoot - Force to install the dependencies in the workspace root (optional, default = false)\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithPNPM(dependencies: string[], type: DependencyType, addAtRoot = false): string[] {\n let command = ['add']\n\n if (addAtRoot) {\n command.push('-w')\n }\n\n command = command.concat(dependencies)\n\n switch (type) {\n case 'dev':\n command.push('--save-dev')\n break\n case 'peer':\n command.push('--save-peer')\n break\n case 'prod':\n command.push('--save-prod')\n break\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using Bun.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithBun(dependencies: string[], type: DependencyType): string[] {\n let command = ['add']\n\n command = command.concat(dependencies)\n\n switch (type) {\n case 'dev':\n command.push('--development')\n break\n case 'peer':\n command.push('--optional')\n break\n case 'prod':\n break\n }\n return command\n}\n\n/**\n * Given a directory it traverses the directory up looking for a package.json and if found, it reads it\n * decodes the JSON, and returns its content as a Javascript object.\n * @param options - The directory from which traverse up.\n * @returns If found, the promise resolves with the path to the\n * package.json and its content. If not found, it throws a FindUpAndReadPackageJsonNotFoundError error.\n */\nexport async function findUpAndReadPackageJson(fromDirectory: string): Promise<{path: string; content: PackageJson}> {\n const packageJsonPath = await findPathUp('package.json', {cwd: fromDirectory, type: 'file'})\n if (packageJsonPath) {\n const packageJson = JSON.parse(await readFile(packageJsonPath))\n return {path: packageJsonPath, content: packageJson}\n } else {\n throw new FindUpAndReadPackageJsonNotFoundError(fromDirectory)\n }\n}\n\nexport async function addResolutionOrOverride(directory: string, dependencies: {[key: string]: string}): Promise<void> {\n const packageManager = await getPackageManager(directory)\n const packageJsonPath = joinPath(directory, 'package.json')\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n\n if (packageManager === 'yarn') {\n packageJsonContent.resolutions = packageJsonContent.resolutions\n ? {...packageJsonContent.resolutions, ...dependencies}\n : dependencies\n }\n if (packageManager === 'npm' || packageManager === 'pnpm' || packageManager === 'bun') {\n packageJsonContent.overrides = packageJsonContent.overrides\n ? {...packageJsonContent.overrides, ...dependencies}\n : dependencies\n }\n\n await writeFile(packageJsonPath, JSON.stringify(packageJsonContent, null, 2))\n}\n\n/**\n * Returns the latest available version of an NPM package.\n * @param name - The name of the NPM package.\n * @returns A promise to get the latest available version of a package.\n */\nasync function getLatestNPMPackageVersion(name: string) {\n outputDebug(outputContent`Getting the latest version of NPM package: ${outputToken.raw(name)}`)\n return runWithTimer('cmd_all_timing_network_ms')(() => {\n return latestVersion(name)\n })\n}\n\n/**\n * Writes the package.json file to the given directory.\n *\n * @param directory - Directory where the package.json file will be written.\n * @param packageJSON - Package.json file to write.\n */\nexport async function writePackageJSON(directory: string, packageJSON: PackageJson): Promise<void> {\n outputDebug(outputContent`JSON-encoding and writing content to package.json at ${outputToken.path(directory)}...`)\n const packagePath = joinPath(directory, 'package.json')\n await writeFile(packagePath, JSON.stringify(packageJSON, null, 2))\n}\n\n/**\n * Infers the package manager to be used based on the provided options and environment.\n *\n * This function determines the package manager in the following order of precedence:\n * 1. Uses the package manager specified in the options, if valid.\n * 2. Infers the package manager from the user agent string.\n * 3. Infers the package manager used for the global CLI installation.\n * 4. Defaults to 'npm' if no other method succeeds.\n *\n * @param optionsPackageManager - The package manager specified in the options (if any).\n * @returns The inferred package manager as a PackageManager type.\n */\nexport function inferPackageManager(optionsPackageManager: string | undefined, env = process.env): PackageManager {\n if (optionsPackageManager && packageManager.includes(optionsPackageManager as PackageManager)) {\n return optionsPackageManager as PackageManager\n }\n const usedPackageManager = packageManagerFromUserAgent(env)\n if (usedPackageManager !== 'unknown') return usedPackageManager\n\n const globalPackageManager = inferPackageManagerForGlobalCLI()\n if (globalPackageManager !== 'unknown') return globalPackageManager\n\n return 'npm'\n}\n"]}
|