Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

V4P4: feat(buildpack): scaffolding creation #1500

Merged
merged 8 commits into from
Sep 26, 2019

Conversation

zetlen
Copy link
Contributor

@zetlen zetlen commented Jul 31, 2019

Description

Scaffolding tools to create new projects that use PWA Studio as a framework.

Closes #1693.

New features

  • A create-project subcommand in the buildpack CLI.
  • A new package, @magento/create-pwa, that launches an interactive questionnaire as a more friendly interface to buildpack create-project and its many arguments. 🎉 This project's name begins with create, so any NPM user can start a new project with npm init @magento/pwa or yarn create @magento/pwa.
  • A structure and API for creating your own templates to use for scaffolding, using the new convention of a _buildpack directory in your project root.

Notes

  • Currently only venia-concept is tested and supported. The system is built so that it'll be easy in the future to expand this to using any NPM package.
  • Experiment: This introduces the first use of the _buildpack directory, which should contain helper modules and utilities for manipulating PWA Studio code. The _buildpack/create.js is used to generate a visitor for buildpack to use when copying the directory over. Implementing _buildpack/create.js in a repository makes it "shareable"; the dev is responsible for writing any custom code in that module which would ease the transitions.

Verification Steps

buildpack create-project Verification Steps

  1. Use a clean install from the repository.
  2. Set the environment variable DEBUG_PROJECT_CREATION=1. This is required for it to work in the core repository.
  3. Run the following command:
 DEBUG_PROJECT_CREATION=1 ./pwa-studio/packages/pwa-buildpack/bin/buildpack create-project mytest --template "venia-concept" --name "mytestName" --author "zetlen <jzetlen@adobe.com>" --backend-url "https://release-dev-231-npzdaky-zddsyhrdimyra.us-4.magentosite.cloud/" --npm-client "yarn" && cd mytest && yarn watch
  1. Observe the creation of a brand new project.

npm init @magento/pwa Verification Steps

An NPM package whose name begins with create- (disregarding @scope) can be used as a project generator. It is expected to expose one CLI command that will be run when a developer runs npm init <package_name_minus_create_prefix>.

Our initializer is called @magento/create-pwa, so the command to use it in NPM is:

 DEBUG_PROJECT_CREATION=1 npm init @magento/pwa

Or in Yarn:

 DEBUG_PROJECT_CREATION=1 yarn create @magento/pwa

ℹ️ Warning: Yarn can't use globally linked modules in its "create", so it's hard to test the Yarn command.

  1. From a fresh clone and install of the repo:
  2. cd packages/pwa-buildpack
  3. yarn link
  4. cd ../create-pwa
  5. yarn link @magento/pwa-buildpack
  6. cd to the root directory
  7. Run DEBUG_PROJECT_CREATION=1 npm init @magento/pwa and answer the questions

Expected Result: Jubilance and pride.

Proposed Labels for Change Type/Package

  • major (e.g x.0.0 - a breaking change)
  • minor (e.g 0.x.0 - a backwards compatible addition)
  • patch (e.g 0.0.x - a bug fix)

Checklist:

  • I have updated the documentation accordingly, if necessary.
  • I have added tests to cover my changes, if necessary.

@vercel
Copy link

vercel bot commented Jul 31, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://pwa-studio-git-zetlen-v4apip4-scaffolding-generator.magento.now.sh

@zetlen zetlen changed the title feat(buildpack): scaffolding creation V4P4: feat(buildpack): scaffolding creation Jul 31, 2019
@coveralls
Copy link

coveralls commented Jul 31, 2019

Coverage Status

Coverage decreased (-1.7%) to 74.513% when pulling 78713a2 on zetlen/v4api/p4-scaffolding-generator into bdec035 on zetlen/v4api/p3-move-venia-components-to-lib.

@zetlen zetlen force-pushed the zetlen/v4api/p3-move-venia-components-to-lib branch from 916a20a to bdec035 Compare July 31, 2019 15:29
@zetlen zetlen force-pushed the zetlen/v4api/p4-scaffolding-generator branch from a06986d to 78713a2 Compare July 31, 2019 15:30
@zetlen zetlen force-pushed the zetlen/v4api/p3-move-venia-components-to-lib branch 2 times, most recently from bc5802a to 7974942 Compare July 31, 2019 16:15
@cherdman cherdman added the version: Minor This changeset includes functionality added in a backwards compatible manner. label Jul 31, 2019
@zetlen zetlen force-pushed the zetlen/v4api/p3-move-venia-components-to-lib branch from 7974942 to 39a3496 Compare August 7, 2019 13:30
@zetlen zetlen force-pushed the zetlen/v4api/p4-scaffolding-generator branch from 78713a2 to d012d6a Compare August 7, 2019 13:32
@zetlen zetlen force-pushed the zetlen/v4api/p3-move-venia-components-to-lib branch from 39a3496 to ca4e096 Compare August 8, 2019 19:14
@zetlen zetlen force-pushed the zetlen/v4api/p4-scaffolding-generator branch from d32b057 to a21e951 Compare August 12, 2019 13:21
@PWAStudioBot
Copy link
Contributor

PWAStudioBot commented Aug 12, 2019

Messages
📖

Access a deployed version of this PR here. Make sure to wait for the "pwa-pull-request-deploy" job to complete.

📖 DangerCI Failures related to missing labels/description/linked issues/etc will persist until the next push or next nightly build run (assuming they are fixed).

Generated by 🚫 dangerJS against fc631d6

@zetlen zetlen force-pushed the zetlen/v4api/p3-move-venia-components-to-lib branch 2 times, most recently from da3a266 to 0613e32 Compare August 12, 2019 22:10
@zetlen zetlen force-pushed the zetlen/v4api/p4-scaffolding-generator branch from a21e951 to 00ec457 Compare August 12, 2019 22:11
@Jordaneisenburger
Copy link
Member

2. cd packages/pwa-buildback

The pwa-buildBack typo got me for a second there, I should stop with the copy pasting habit

@zetlen
Copy link
Contributor Author

zetlen commented Sep 22, 2019

@Jordaneisenburger Whoops! Corrected.

@dpatil-magento dpatil-magento merged commit baa1e00 into develop Sep 26, 2019
@dpatil-magento dpatil-magento deleted the zetlen/v4api/p4-scaffolding-generator branch September 26, 2019 16:36
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature]: NPM initializer for "npm init" to make a new PWA
9 participants