Repository navigation
refactor(init): fold Platformify into the CLI - #252
Conversation
Copy the Platformify code that `init` uses (the guided wizard and its templates) from github.com/platformsh/platformify at dc7b173 (main, three commits after v0.5.0), and drop the module dependency. Left out: the standalone binaries, the `validate` command and the `validator` package with its schemas, which `lint` replaced. The platformifier tests now check the generated config with pkg/lint. Its stricter checks showed that the test fixtures were unlike real input (the type and runtime were swapped, and names and service types were invalid), so the fixtures are corrected. Refs CLI-184. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge the imported Platformify packages into internal/platformify, and pass the wizard's state explicitly instead of through context values. - Replace vendorization with values from the CLI config, which removes the vendor assets from the root command. - Write to the Git root that init already finds, instead of asking to change directory there. Drop the message for projects outside Git, as init requires a repository. - Render templates into a map of files and write them afterwards, which replaces the file system interface and the generated mocks. - Take runtime and service versions from pkg/registry, instead of a generated list from the docs registry. - Remove the no-op Next.js generator and its missing template paths, and the unused dependency managers in the template input. Fixes: - Keep the case of values read from package.json, e.g. "main". - Detect the "shopware" composer keyword, which was never matched. - Skip a service without known versions instead of dropping the rest. - Use $SOCKET in the placeholder web command, not $UNIX. - Use a slash-separated application root on Windows. Template output is unchanged for the existing fixtures (compared before and after). New tests cover stack detection and generated files, which are checked with pkg/lint for Flex and Fixed configuration. Refs CLI-184. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 5 warnings · 🔵 1 minor point
🔍 Full review · 27 files reviewed
Verification
- The flex and fixed templates are byte-identical to platformify v0.5.0's upsun and generic templates (checked with diff against the module cache).
- The step order in
Runmatches the original questionnaire, minus WorkingDirectory, which is replaced by passing the Git root asDir. - When a selected service has no versions in
askServices, the code now skips it withcontinue; the original code returned early and dropped the remaining services. - Shopware detection in
isSymfonymatches psr-4 keys and keywords case-insensitively throughlookupFold/EqualFold, like the original's lowercasing of the whole file. - No caller is left using the old
newRootCommand/newInitCommandsignatures or thevendorizationpackage;go vetandgo test ./internal/platformifypass.
The new internal/platformify tests check stack detection, build steps, and the generated Flex and Fixed config for each fixture, validated with pkg/lint.CheckDir. CI runs them in the make test-go job. No test exercises Run's step order or the survey prompts. That is why the subdirectory application-root problems above go unnoticed: the fixtures set ApplicationRoot directly.
Review details
- Commit: 9a23163
- Model: claude-opus-5-5
Review 1 of 10 for this pull request · View the full run
Fix problems inherited from Platformify, found in review: - Detect the application root before the steps that use it, and resolve the PHP web root, package.json, index.js and the Flask app from it, so that an app in a subdirectory gets paths that exist. - Write .environment, and on Fixed .platform.app.yaml, in the application root, where they are read. - Ask about overwriting once the application root is known, listing the files that would be generated, and list the written files when done. This drops .platform/applications.yaml, which was never written. - Export REDIS_URL for Redis Persistent: the template compared the cache to "redis_persistent", which never matched. - Set DATABASE_SCHEME for Strapi on Fixed from $DB_SCHEME: $DB_CONNECTION is only set for Laravel. - Quote relationship names in jq paths on Fixed, as jq parsed names such as "redis-persistent" as a subtraction. - Render relationships from the service names, and drop the unused endpoint mapping. Refs CLI-184. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
📋 PR Summary This PR moves the guided Changes
|
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 1 warning
🔁 Incremental · 11 files reviewed
Verification
detectApplicationRootnow runs beforesetLocations/setBuildSteps/setWebCommand. Those steps read files relative toappDir(), so the PHP location root,scripts.buildcheck,index.jsfallback and Flask entry point are all resolved inside the app's own directory.outputPathputs.environmentand.platform.app.yamlin the app root. For a root app it gives.environment, sincepath.Join("/", ".environment")with the leading slash trimmed is.environment. Shared.platform/*and.upsun/config.yamlfiles stay at the project root.- Fixed jq paths now use
.["name"], soredis-persistentresolves, and both templates matchredis-persistentwith a hyphen, which is the service nameaskServicesproduces. confirmOverwritekeeps Django's appendedsettings.pyout of the overwrite list because the generated content starts with the current file contents (bytes.HasPrefix).donelists the keys of the rendered file map, so it no longer names.platform/applications.yaml, which no template generates.
New tests cover this: TestSubdirectoryApp (detection for Laravel, Express and Flask apps in a subdirectory), TestGenerateSubdirectoryApp (output paths for Flex and Fixed), TestGenerateRedisPersistent and TestGenerateStrapiDatabaseScheme. No test covers confirmOverwrite when config files already exist at the root.
Review 2 of 10 for this pull request · View the full run
The overwrite check only looked at the files the wizard generates, so on Fixed an app config at another path (e.g. a root .platform.app.yaml when the app is now in a subdirectory, or .platform/applications.yaml) was kept without a warning, and could define a conflicting app. List those files, and other .upsun/*.yaml files on Flex, as kept, and ask whether to continue. Refs CLI-184. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guided wizard has moved into the Upsun CLI (upsun/cli#252). Point users to `upsun init` and the Upsun AI toolkit. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Moves the guided
initwizard (Platformify) intointernal/platformifyand drops thegithub.com/platformsh/platformifydependency. The wizard stays because it supports Fixed configuration, which the AI mode doesn't (see #249).Three commits:
Import: copies the code from platformsh/platformify at
dc7b173, without the standalone binaries, thevalidatecommand or thevalidatorschemas (lintreplaced those). Tests check generated config withpkg/lint, which showed the test fixtures didn't match real input, so they're corrected.Simplify: merges the packages into one, and passes the wizard's state explicitly instead of through context values.
initalready finds.golang/mock).pkg/registry, not a generated list.package.jsonkeep their case, theshopwarekeyword is now detected, services without known versions no longer drop the rest, the placeholder web command uses$SOCKET, and the application root is slash-separated on Windows.Review fixes (bugs inherited from Platformify): apps in a subdirectory get paths resolved from their application root, and
.environment(and on Fixed,.platform.app.yaml) is written there. The overwrite prompt and final message list the files actually generated. Template fixes:REDIS_URLfor Redis Persistent,DATABASE_SCHEMEfor Strapi on Fixed, and quoted jq paths for hyphenated relationship names on Fixed.After this merges, platformsh/platformify can be archived.
🤖 Generated with Claude Code