Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added ability to use custom template for scaffolding. #3025

Merged
merged 13 commits into from
Mar 15, 2021

Conversation

revanth0212
Copy link
Contributor

@revanth0212 revanth0212 commented Feb 25, 2021

Description

This PR adds the ability to request the scaffolding program to use a custom template/version while creating a new project.

image

Related Issue

Closes PWA-483

Acceptance

Should be able to scaffold a new project using any compatible template on NPM.

Verification Stakeholders

@jimbo @dpatil-magento

Specification

Need to update docs the mention the same.

Verification Steps

Note: This won't work yet with yarn create @magento/pwa because we did not publish the new @magento/create-pwa yet. So let's test this using the new unpublished version locally.

  1. Go to a folder where you would like to scaffold the new project.
  2. In terminal run node PATH_TO_PWA_STUDIO/packages/create-pwa/bin/create-pwa
  3. Answer all the questions.
  4. For the question Which template would you like to use to bootstrap test? Defaults to venia-concept. enter any version from NPM. For instance: @magento/venia-concept@9.0.1-alpha.3. If you don't provide anything, it would check in the file system for venia-concept. If it can not find that, then it would search for a venia-concept in the local machine cache and use that instead.

Checklist

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

@PWAStudioBot
Copy link
Contributor

PWAStudioBot commented Feb 25, 2021

Messages
📖

Associated JIRA tickets: PWA-483.

📖 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).
📖

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

Generated by 🚫 dangerJS against ef00b5b

@revanth0212 revanth0212 changed the title Revanth/custom version label Added ability to use custom template for scaffolding. Feb 26, 2021
@revanth0212 revanth0212 added the version: Minor This changeset includes functionality added in a backwards compatible manner. label Feb 26, 2021
@revanth0212 revanth0212 marked this pull request as ready for review February 26, 2021 16:40
@larsroettig larsroettig self-requested a review February 28, 2021 10:32
larsroettig
larsroettig previously approved these changes Feb 28, 2021
Copy link
Member

@larsroettig larsroettig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ✔️ CodeRevbiew
  • ✔️ TestCoverage
  • ✔️ Mannual QA

Copy link
Contributor

@sirugh sirugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see the default be @magento/venia-concept if possible. But this is great and allows people to target a specific template version! So simple...why didn't we do this before 🤣

name: 'template',
message: ({ name }) =>
`Which template would you like to use to bootstrap ${name}? Defaults to venia-concept.`,
default: 'venia-concept'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a difference between @magento/venia-concept and venia-concept? If not maybe we can use the namespaced version since it is similar to how a user would define by version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are maintaining an array which will be matched against first. If that doesn't work, that's when the code looks to pull the package from NPM. The object that we have in that array is looking for venia-concept. You are right, what you mentioned is what the code does but right now the way the code is laid out works this way:

if template === 'venia-concept`
    // use local mapping to find the local venia-concept package
else if template === anything other than `venia-concept`
   // check inside mac cache and if it does not find that package, fetch from NPM
   // if template is `@magento/venia-concept` use the latest stable version
   // if template has a version string attached, use the package with that particular version.

If we change the default to @magento/venia-concept instead, we won't be able to use local packages while developing. There definitely will be a way to do that, but do we need to spend more time on that? I did think about what you mentioned but opted out personally, but wanted to check with the team. Thanks for bringing this up buddy. Good question.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed in dev time and I think we want to be pretty explicit here to avoid the "magic" that helped obscure the release bug.

Basically the target template input text should be the deployed name of the package, as if you were doing a yarn add ie https://classic.yarnpkg.com/en/docs/cli/add/. So in this case, defaulting to @magento/venia-concept is fine, but it should default to fetch the latest release version from remote, not local. To use local we would be explicit such as template: file:/path/to/local/folder.

I think the team had input so if you want to start a thread on slack about it, let's do it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, handled.

await execa.shell(`${buildpackBinLoc} ${argsString}`, {
stdio: 'inherit'
});
} catch (e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a small change. Moved catch statement to the end of the function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the call out! You can see this by appending ?w=1 :) https://github.com/magento/pwa-studio/pull/3025/files?w=1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know 👍

sirugh
sirugh previously approved these changes Mar 9, 2021
Copy link
Contributor

@sirugh sirugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preliminary approval so we can get this in QA. The last of my comments have really been minor string changes which I'd like to see updated but no sense in delaying things.

Co-authored-by: Stephen <sirugh@users.noreply.github.com>
sirugh
sirugh previously approved these changes Mar 9, 2021
@dpatil-magento
Copy link
Contributor

@revanth0212 Project built with local (packages/venia-concept) repo has errors after launching Venia and also storybook build fails.

@dpatil-magento
Copy link
Contributor

QA Approved.

sirugh
sirugh previously approved these changes Mar 15, 2021
@dpatil-magento dpatil-magento merged commit e32bdff into develop Mar 15, 2021
@sirugh sirugh deleted the revanth/custom_version_label branch April 26, 2021 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:create-pwa pkg:pwa-buildpack Progress: done version: Minor This changeset includes functionality added in a backwards compatible manner.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants