├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .github
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE.md
├── PULL_REQUEST_TEMPLATE.md
└── SUPPORT.md
├── .gitignore
├── .npmignore
├── .prettierrc
├── CHANGELOG.md
├── LICENSE.txt
├── README.md
├── buildpack-logo.icns
├── circle.yml
├── docs
├── MagentoResolver.md
├── MagentoRootComponentsPlugin.md
├── PWADevServer.md
├── ServiceWorkerPlugin.md
└── magento-layout-loader.md
├── package-lock.json
├── package.json
└── src
├── ExtensionComponentWrap
├── .babelrc
├── .eslintrc.js
└── index.js
├── WebpackTools
├── MagentoResolver.js
├── PWADevServer.js
├── __tests__
│ ├── MagentoResolver.spec.js
│ └── PWADevServer.spec.js
├── index.js
├── middlewares
│ ├── DevProxy.js
│ ├── OriginSubstitution.js
│ ├── StaticRootRoute.js
│ ├── __fixtures__
│ │ └── root-available-file.json
│ └── __tests__
│ │ ├── DevProxy.spec.js
│ │ ├── OriginSubstitution.spec.js
│ │ └── StaticRootRoute.spec.js
└── plugins
│ ├── MagentoRootComponentsPlugin
│ ├── __tests__
│ │ ├── MagentoRootComponentsPlugin.spec.js
│ │ └── __fixtures__
│ │ │ ├── basic-project-1-page
│ │ │ ├── RootComponents
│ │ │ │ └── SomePage
│ │ │ │ │ └── index.js
│ │ │ └── entry.js
│ │ │ ├── basic-project-3-pages
│ │ │ ├── RootComponents
│ │ │ │ ├── Page1
│ │ │ │ │ └── index.js
│ │ │ │ ├── Page2
│ │ │ │ │ └── index.js
│ │ │ │ └── Page3
│ │ │ │ │ └── index.js
│ │ │ └── entry.js
│ │ │ ├── dupe-root-component
│ │ │ ├── RootComponents
│ │ │ │ └── Page1
│ │ │ │ │ └── index.js
│ │ │ └── entry.js
│ │ │ ├── missing-root-directive
│ │ │ ├── RootComponents
│ │ │ │ └── Page1
│ │ │ │ │ └── index.js
│ │ │ └── entry.js
│ │ │ └── root-component-dep
│ │ │ ├── RootComponents
│ │ │ └── Page1
│ │ │ │ └── index.js
│ │ │ ├── dep.js
│ │ │ └── entry.js
│ ├── index.js
│ └── roots-chunk-loader.js
│ ├── ServiceWorkerPlugin.js
│ └── __tests__
│ └── ServiceWorkerPlugin.spec.js
├── __tests__
└── __fixtures__
│ └── extensions
│ ├── extension1
│ └── extension.json
│ ├── extension2
│ └── extension.json
│ └── random-file.txt
├── index.js
├── magento-layout-loader
├── __tests__
│ ├── __fixtures__
│ │ └── only-entry
│ │ │ └── index.js
│ ├── __snapshots__
│ │ └── babel-plugin-magento-layout.spec.js.snap
│ ├── babel-plugin-magento-layout.spec.js
│ ├── magento-layout-loader.spec.js
│ └── validateConfig.spec.js
├── babel-plugin-magento-layout.js
├── index.js
└── validateConfig.js
└── util
├── __tests__
├── debug.spec.js
├── global-config.spec.js
├── options-validator.spec.js
├── run-as-root.spec.js
└── ssl-cert-store.spec.js
├── debug.js
├── global-config.js
├── options-validator.js
├── promisified
├── child_process.js
├── dns.js
├── fs.js
└── openport.js
├── run-as-root.js
└── ssl-cert-store.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "env",
5 | {
6 | "targets": {
7 | "node": [
8 | "8"
9 | ]
10 | }
11 | }
12 | ]
13 | ],
14 | "plugins": [
15 | ["transform-class-properties", { "spec": true }]
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 4
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [{package.json,*.yml}]
12 | indent_style = space
13 | indent_size = 2
14 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | __fixtures__
2 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | const config = {
2 | parser: 'babel-eslint',
3 | parserOptions: {
4 | sourceType: 'script'
5 | },
6 | extends: ['@magento', "plugin:node/recommended"],
7 | plugins: [
8 | "babel",
9 | "node"
10 | ]
11 | };
12 |
13 | module.exports = config;
14 |
--------------------------------------------------------------------------------
/.github/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | education, socio-economic status, nationality, personal appearance, race,
10 | religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at pwa@magento.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Thank you for your interest in contributing to the pwa-buildpack project! Before you start contributing, please take a moment to read through the following guidelines:
4 |
5 | * [Code of Conduct]
6 | * [Support]
7 |
8 | To contribute to this repository, start by forking the [official repository] and following the installation instructions in the README file.
9 |
10 | ## Pull Request checklist
11 |
12 | * PR commits should contain [meaningful commit messages]
13 | * To help with reviews, your PR should only create/revise a single feature or fix a single issue.
14 | * If your PR fixes a bug, please provide a step-by-step description of how to reproduce the bug.
15 | * If your PR addresses an existing issue, please reference that issue in the title or description.
16 |
17 | ## Contribution process
18 |
19 | Magento maintains a public roadmap for this and other [Magento Research] repositories in each project's issue board.
20 |
21 | Any and all community participation in this backlog is encouraged and appreciated.
22 | Even foundational infrastructure stories are available for a generous developer to take on.
23 |
24 | To get started, look for issues tagged with the **[help wanted]** labels.
25 | These issues are ready for community ownership.
26 |
27 | **Note:**
28 | *We also accept unsolicited new issues/features and pull request, but priority is given to issues in our roadmap that community developers have been kind enough to take on.*
29 |
30 | ### Claiming an issue on the roadmap
31 |
32 | If you are interested in taking ownership of a roadmap feature or issue, we ask that you go through the following process.
33 | This helps us organize and forecast the progress of our projects.
34 |
35 | #### Step 1: Add an issue comment
36 |
37 | Add a comment on an issue expressing your interest in taking ownership of it.
38 | Make sure your GitHub profile includes an email address so we can contact you privately.
39 |
40 | #### Step 2: Meet with a maintainer
41 |
42 | A maintainer will contact you and ask to set up a real-time meeting to discuss the issue you are interested in owning.
43 | This meeting can be in person, video chat, audio chat, or text chat.
44 |
45 | In general this meeting is brief but can vary with the complexity of an issue.
46 | For larger issues, we may schedule follow-up meetings.
47 |
48 | During this meeting, we provide you with any additional materials or resources you need to work on the issue.
49 |
50 | #### Step 3: Provide an estimate
51 |
52 | We ask that you provide us an estimate of how long it will take you to complete the issue.
53 |
54 | If you require more time to provide a time frame for completion, you are allowed to take up to five business days to think about it.
55 |
56 | If you can't get back to us by that time, we understand!
57 | As a community developer, you are helping us out in addition to your regular job.
58 | We will un-assign you from this issue, but please feel free to contribute to another issue.
59 |
60 | #### Step 4: Work on the issue
61 |
62 | After you provide an estimate, the issue is now "in progress", and
63 | you officially become a member of the [Magento Research] organization.
64 |
65 | If you need more time to work on the issue, please contact us as soon as possible.
66 | We may request an update on your progress, but we are willing to accomodate.
67 |
68 | If the deadline you provided to us passes and we have not heard from you, we will wait one week before un-assigning you from the issue.
69 |
70 | #### Step 5: Create a pull request
71 |
72 | When you finish working on an issue, create a pull request with the issue number included in the title or body.
73 | This starts the (brief) code review process.
74 |
75 | After we accept and merge your contribution, you become an official contributor!
76 | Official contributors are invited to our backlog grooming sessions and have direct influence over the product roadmap.
77 |
78 | We hope this guide paints a clear picture of your duties and expectations in the contribution process. Thank you in advance for helping with our research projects!
79 |
80 | ## Report an issue
81 |
82 | Create a [GitHub issue] and put an **X** in the appropriate box to report an issue with the project.
83 | Provide as much detail as you can in each section to help us triage and process the issue.
84 |
85 | ### Issue types
86 |
87 | * Bug - An error, flaw, or failure in the code
88 | * Feature suggestion - A missing feature you would like to see implemented in the project
89 | * Other - Any other type of task related to the project
90 |
91 | **Note:**
92 | *Please avoid creating GitHub issues asking for help on bugs in your project that are outside the scope of this project.*
93 |
94 | [Code of Conduct]: CODE_OF_CONDUCT.md
95 | [Support]: SUPPORT.md
96 | [official repository]: https://github.com/magento-research/pwa-buildpack
97 | [meaningful commit messages]: https://chris.beams.io/posts/git-commit/
98 | [GitHub issue]: https://github.com/magento-research/pwa-buildpack/issues/new
99 | [Magento Research]: https://github.com/magento-research
100 | [help wanted]: https://github.com/magento-research/pwa-buildpack/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 | ## This issue is a:
3 | [ ] Bug
4 | [ ] Feature suggestion
5 | [ ] Other
6 |
7 |
8 | ## Description:
9 |
10 |
11 | ### Environment and steps to reproduce
12 |
13 | OS:
14 |
15 | Magento 2 version:
16 |
17 | Other environment information:
18 |
19 | Steps to reproduce:
20 |
21 | 1. First Step
22 | 2. Second Step
23 | 3. Etc.
24 |
25 |
26 | ## Expected result:
27 |
28 |
29 | ## Possible solutions:
30 |
31 |
32 | ## Additional information:
33 |
34 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 | ## This PR is a:
3 | [ ] New feature
4 | [ ] Enhancement/Optimization
5 | [ ] Refactor
6 | [ ] Bugfix
7 | [ ] Test for existing code
8 | [ ] Documentation
9 |
10 |
11 | ## Summary
12 |
13 | When this pull request is merged, it will...
14 |
15 |
16 | ## Additional information
17 |
18 |
--------------------------------------------------------------------------------
/.github/SUPPORT.md:
--------------------------------------------------------------------------------
1 | # Support
2 |
3 | Need help with something? Please use the following resources to get the help you need:
4 |
5 | * Documentation website - [PWA DevDocs]
6 | * Chat with us on **Slack** - [#pwa channel]
7 | * Send us an Email: pwa@magento.com
8 |
9 | [PWA DevDocs]: https://magento-research.github.io/pwa-devdocs/
10 | [#pwa channel]: https://magentocommeng.slack.com/messages/C71HNKYS2
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 | .DS_Store
4 | coverage
5 | dist
6 | test-report.xml
7 | .vscode
8 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | __tests__
2 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "trailingComma": "none",
4 | "tabWidth": 4
5 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4 |
5 |
6 | ## [0.8.2](https://github.com/magento-research/pwa-buildpack/compare/v0.8.1...v0.8.2) (2018-05-26)
7 |
8 |
9 | ### Bug Fixes
10 |
11 | * update devcert dependency ([ed4c1d5](https://github.com/magento-research/pwa-buildpack/commit/ed4c1d5))
12 |
13 |
14 |
15 |
16 | ## [0.8.1](https://github.com/magento-research/pwa-buildpack/compare/v0.7.1...v0.8.1) (2018-05-26)
17 |
18 |
19 | ### Bug Fixes
20 |
21 | * remove buggy sudo-prompt until fallback works ([#39](https://github.com/magento-research/pwa-buildpack/issues/39)) ([99828aa](https://github.com/magento-research/pwa-buildpack/commit/99828aa)), closes [#35](https://github.com/magento-research/pwa-buildpack/issues/35)
22 |
23 |
24 |
25 |
26 | ## [0.7.1](https://github.com/magento-research/pwa-buildpack/compare/v0.7.0...v0.7.1) (2018-05-15)
27 |
28 |
29 | ### Bug Fixes
30 |
31 | * **DevProxy:** put proxy after other middlewares ([#33](https://github.com/magento-research/pwa-buildpack/issues/33)) ([6378414](https://github.com/magento-research/pwa-buildpack/commit/6378414)), closes [#32](https://github.com/magento-research/pwa-buildpack/issues/32)
32 |
33 |
34 |
35 |
36 | # [0.7.0](https://github.com/magento-research/pwa-buildpack/compare/v0.6.0...v0.7.0) (2018-05-03)
37 |
38 |
39 | ### Bug Fixes
40 |
41 | * **util:** fix run-as-root await rm bug ([#28](https://github.com/magento-research/pwa-buildpack/issues/28)) ([8a71a9f](https://github.com/magento-research/pwa-buildpack/commit/8a71a9f)), closes [magento-research/venia-pwa-concept#51](https://github.com/magento-research/venia-pwa-concept/issues/51)
42 |
43 |
44 | ### Features
45 |
46 | * add protocol error detection to devproxy ([#22](https://github.com/magento-research/pwa-buildpack/issues/22)) ([aa0e53c](https://github.com/magento-research/pwa-buildpack/commit/aa0e53c))
47 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | Open Software License ("OSL") v. 3.0
4 |
5 | This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
6 |
7 | Licensed under the Open Software License version 3.0
8 |
9 | 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
10 |
11 | 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
12 |
13 | 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
14 |
15 | 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
16 |
17 | 4. to perform the Original Work publicly; and
18 |
19 | 5. to display the Original Work publicly.
20 |
21 | 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
22 |
23 | 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
24 |
25 | 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
26 |
27 | 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
28 |
29 | 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
30 |
31 | 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
32 |
33 | 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
34 |
35 | 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
36 |
37 | 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
38 |
39 | 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
40 |
41 | 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
42 |
43 | 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
44 |
45 | 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
46 |
47 | 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
48 |
49 | 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
50 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This repository is no longer maintained. Please visit the [PWA Studio](https://github.com/magento-research/pwa-studio) repository which now contains all PWA Studio packages in one place.
2 |
--------------------------------------------------------------------------------
/buildpack-logo.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/magento-research/pwa-buildpack/868805288d6d5cc16a87382d50a4a89e2fd8be0a/buildpack-logo.icns
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | node:
3 | version: 8
4 | environment:
5 | TEST_REPORT_PATH: $CIRCLE_TEST_REPORTS/
6 |
--------------------------------------------------------------------------------
/docs/MagentoResolver.md:
--------------------------------------------------------------------------------
1 | # MagentoResolver
2 |
3 | An adapter that configures Webpack to resolve assets according to Magento PWA conventions.
4 |
5 | ## Purpose
6 |
7 | Generates a configuration for use in the [`resolve` property of Webpack config](https://webpack.js.org/configuration/resolve/).
8 | Describes how to traverse the filesystem structure for assets required in source
9 | files.
10 |
11 | This class generates a configuration object for the `resolve` property of a
12 | Webpack config file. The configuration object describes how Webpack should
13 | traverse the filesystem structure to retrieve assets required in source files.
14 |
15 | Currently, `MagentoResolver` does very little, but it's likely that the Magento
16 | development environment will require custom resolution rules in the future; this
17 | utility sets the precedent of the API for delivering those rules.
18 |
19 | ## Usage
20 |
21 | In `webpack.config.js`:
22 |
23 | ```js
24 | const buildpack = require('@magento/pwa-buildpack');
25 | const MagentoResolver = buildpack.Webpack.MagentoResolver;
26 |
27 | module.exports = async env => {
28 | const config {
29 | /* webpack entry, output, rules, etc */
30 |
31 |
32 | resolve: await MagentoResolver.configure({
33 | paths: {
34 | root: __dirname
35 | }
36 | })
37 |
38 | };
39 |
40 | return config;
41 | }
42 | ```
43 |
44 | - ℹ️ **Note:** `MagentoResolver.configure()` is asynchronous and returns a
45 | Promise. For more information, see the Webpack documentation about
46 | [Exporting a Promise configuration type](https://webpack.js.org/configuration/configuration-types/#exporting-a-promise).
47 |
48 | In the example provided, lhe newer `async/await` syntax is used because it is
49 | a cleaner alternative to using Promses directly.
50 |
51 | ### API
52 |
53 | #### `MagentoResolver.configure(options: ResolverOptions): Promise`
54 |
55 | #### `options`
56 |
57 | - `paths: object`: **Required.** Local absolute paths to theme folders.
58 | - `root`: Absolute path to the root directory of the theme.
59 |
--------------------------------------------------------------------------------
/docs/MagentoRootComponentsPlugin.md:
--------------------------------------------------------------------------------
1 | # MagentoRootComponentsPlugin
2 |
3 | Automagically creates [unique
4 | chunks](https://webpack.js.org/guides/code-splitting/) for each Root Component
5 | in a Magento PWA theme and extensions.
6 |
7 | Given a `RootComponents` directory in a theme with the following structure:
8 |
9 | ```sh
10 | ├── Page1
11 | │ └── index.js
12 | ├── Page2
13 | │ └── index.js
14 | └── Page3
15 | └── index.js
16 | ```
17 |
18 | a unique chunk will be generated for `Page1`, `Page2`, and `Page3`. Further
19 | `webpack` optimization techniques (`CommonsChunkPlugin` et al) can be applied as
20 | usual.
21 |
22 | ## Usage
23 |
24 | ```js
25 | // webpack.config.js
26 |
27 | const path = require('path');
28 | const { MagentoRootComponentsPlugin } = require('@magento/pwa-buildpack');
29 |
30 | module.exports = {
31 | entry: {
32 | main: path.join(__dirname, 'src')
33 | },
34 | output: {
35 | path: path.join(__dirname, 'dist'),
36 | filename: '[name].js',
37 | chunkFilename: '[name].chunk.js'
38 | },
39 | plugins: [
40 | new MagentoRootComponentsPlugin({
41 | rootComponentsDirs: [path.join(__dirname, 'src/RootComponents')], // optional
42 | manifestFileName: 'roots-manifest.json' // optional
43 | })
44 | ]
45 | };
46 | ```
47 |
--------------------------------------------------------------------------------
/docs/PWADevServer.md:
--------------------------------------------------------------------------------
1 | # PWADevServer
2 |
3 | Utility for configuring a development OS and a `webpack-dev-server` for PWA
4 | development.
5 |
6 | ## Usage
7 |
8 | In `webpack.config.js`:
9 |
10 | ```js
11 | const path = require('path');
12 | const buildpack = require('@magento/pwa-buildpack');
13 | const PWADevServer = buildpack.Webpack.PWADevServer;
14 |
15 | module.exports = async env => {
16 | const config {
17 | /* webpack entry, output, rules, etc */
18 |
19 | devServer: await PWADevServer.configure({
20 | publicPath: '/pub/static/frontend/Vendor/theme/en_US/',
21 | backendDomain: 'https://magento2.localdomain',
22 | serviceWorkerFileName: 'sw.js',
23 | paths: {
24 | output: path.resolve(__dirname, 'web/js'),
25 | assets: path.resolve(__dirname, 'web')
26 | },
27 | id: 'magento-venia'
28 | })
29 | };
30 |
31 | config.output.publicPath = config.devServer.publicPath;
32 |
33 | return config;
34 | }
35 | ```
36 |
37 | - ⚠️ `PWADevServer.configure()` is async and returns a Promise, so a webpack
38 | config that uses it must use the [Exporting a Promise configuration type](https://webpack.js.org/configuration/configuration-types/#exporting-a-promise).
39 | The newer `async/await` syntax looks cleaner than using Promises directly.
40 | - ⚠️ The emitted `devServer` object may have a custom `publicPath`. For best
41 | ServiceWorker functionality, set `config.output.publicPath` to this value
42 | once the `devServer` is created and before creating a ServiceWorker plugin.
43 |
44 | ### Purpose
45 |
46 | The typical webpack local development scenario uses [the devServer settings in
47 | `webpack.config.js`](https://webpack.js.org/configuration/dev-server/) to create
48 | a temporary local HTTP server for showing edits in real time.
49 |
50 | PWA development has a couple of particular needs:
51 |
52 | - The host must be _secure_ and _trusted_ to allow ServiceWorker operation
53 | - The host must be _unique_ to prevent ServiceWorker collisions
54 |
55 | Furthermore, Magento PWAs are Magento 2 themes running on Magento 2 stores, so
56 | they need to proxy backend requests to the backing store in a customized way.
57 |
58 | PWADevServer` handles all these needs:
59 |
60 | - Creates and caches a custom local hostname for the current theme
61 | - Adds the custom local hostname to `/etc/hosts` 🔐
62 | - Creates and caches an SSL certificate for the custom local hostname
63 | - Adds the certificate to the OS-level keychain so browsers trust it 🔐
64 | - Customizes the `webpack-dev-server` instance to:
65 | - Proxy all asset requests not managed by webpack to the Magento store
66 | - Emulate the public path settings of the Magento store
67 | - Automatically switch domain names in HTML attributes
68 | - Debug or disable ServiceWorkers
69 |
70 | *The 🔐 in the above list indicates that you may be asked for a password at
71 | this step.*
72 |
73 | ### API
74 |
75 | `PWADevServer` has only one method: `.configure(options)`. It returns a Promise
76 | for an object that can be assigned to the `devServer` property in webpack
77 | configuration.
78 |
79 | #### `PWADevServer.configure(options: PWADevServerOptions): Promise`
80 |
81 | #### `options`
82 |
83 | - `id: string`: **Required.** A unique ID for this project. Theme name is
84 | recommended, but you can use any domain-name-safe string. If you're
85 | developing several copies of a theme simultaneously, you can use this ID to
86 | distinguish them in the internal tooling; for example, this id will be used
87 | to create your dev domain name.
88 | - `publicPath: string`: **Required.** The public path of theme assets in the
89 | backend server, e.g. `'/pub/static/frontend/Vendor/themename/en_US'`.
90 | - `backendDomain: string`: **Required.** The URL of the backing store.
91 | - `paths: object`: **Required.** Local absolute paths to theme folders.
92 | - `output`: Directory for built JavaScript files.
93 | - `assets`: Directory for other public static assets.
94 | - `serviceWorkerFileName: string`: **Required.** The name of the ServiceWorker
95 | file this theme creates, e.g. `'sw.js'`.
96 | - `changeOrigin: boolean`: ⚠️ **(experimental)** Try to parse any HTML responses
97 | from the proxied Magento backend, and replace its domain name with the
98 | dev server domain name. Default `false`.
99 |
--------------------------------------------------------------------------------
/docs/ServiceWorkerPlugin.md:
--------------------------------------------------------------------------------
1 | # ServiceWorkerPlugin
2 |
3 | Webpack plugin for configuring a ServiceWorker for different PWA development
4 | scenarios.
5 |
6 | ## Purpose
7 |
8 | This plugin is a wrapper around the [Google Workbox Webpack Plugin](https://developers.google.com/web/tools/workbox/guides/generate-service-worker/).
9 | It generates a caching ServiceWorker based on assets emitted by Webpack.
10 |
11 | This plugin can be configured to run in the following phases:
12 |
13 | - *normal development* - ServiceWorker is disabled
14 | - *service worker debugging* - ServiceWorker and hot-reloading are enabled
15 |
16 | ## Usage
17 |
18 | In `webpack.config.js`:
19 |
20 | ```js
21 | const path = require('path');
22 | const buildpack = require('@magento/pwa-buildpack');
23 | const ServiceWorkerPlugin = buildpack.Webpack.ServiceWorkerPlugin;
24 |
25 | module.exports = async env => {
26 | const config = {
27 | /* webpack config, i.e. entry, output, etc. */
28 | plugins: [
29 | /* other plugins */
30 | new ServiceWorkerPlugin({
31 | env: {
32 | mode: 'development'
33 | },
34 |
35 | paths: {
36 | output: path.resolve(__dirname, 'web/js'),
37 | assets: path.resolve(__dirname, 'web')
38 | },
39 | enableServiceWorkerDebugging: true,
40 | serviceWorkerFileName: 'sw.js',
41 | runtimeCacheAssetPath: 'https://cdn.url'
42 | })
43 | ]
44 | };
45 |
46 | return config;
47 |
48 | };
49 | ```
50 |
51 | ### API
52 |
53 | `ServiceWorkerPlugin(options: PluginOptions): Plugin`
54 | Plugin constructor for the `ServiceWorkerPlugin` class.
55 |
56 | #### `PluginOptions`
57 |
58 | `env: Object` **(Required)**
59 | An object that represents the current environment.
60 | - `env.phase: String` **(Required)**
61 | Must be either `'development'` or `'production'`.
62 |
63 | `paths: Object` **(Required)**
64 | The local absolute paths to theme folders.
65 |
66 | - `paths.assets: String`
67 |
68 | The directory for public static assets.
69 |
70 | `enableServiceWorkerDebugging: Boolean`
71 | When `true`, hot reloading is enabled and the ServiceWorker is active in the document root, regardless of the publicPath value.
72 | When `false`, the ServiceWorker is disabled to prevent cache interruptions when hot reloading assets.
73 |
74 | `serviceWorkerFileName: String` **(Required)**
75 | The name of the ServiceWorker file this theme creates.
76 | Example: `'sw.js'`
77 |
78 | `runtimeCacheAssetPath: String`
79 | A path or remote URL that represents the root path to assets the ServiceWorker should cache as requested during runtime.
80 |
--------------------------------------------------------------------------------
/docs/magento-layout-loader.md:
--------------------------------------------------------------------------------
1 | # magento-layout-loader
2 |
3 | _This is a very early implementation, and the API should be considered
4 | unstable._
5 |
6 | The `magento-layout-loader` is a [webpack
7 | loader](https://webpack.js.org/concepts/loaders/) that transforms
8 | [JSX](https://reactjs.org/docs/introducing-jsx.html) during compilation. It
9 | gives Magento modules/extensions the ability to inject or remove content blocks
10 | in a layout without modifying theme source files.
11 |
12 | ## Terminology
13 |
14 | * **Container**: An HTML element that contains 0 or more ContainerChild
15 | components. It acts as the target for the magento-loader-layout operations.
16 | * **ContainerChild**: Component exposed by
17 | [Peregrine](https://github.com/magento-research/peregrine/). Responsible for
18 | rendering content
19 | * **Operation**: An action that can be taken on a `Container` or
20 | `ContainerChild`. Examples include `removeContainer`, `insertAfter`, etc.
21 |
22 | ## `Container` Details
23 |
24 | A Container can be created by adding a `data-mid` prop to any DOM element
25 | (`div`/`span`/etc) in any React component. There are a limited number of
26 | restrictions with Containers to be aware of:
27 |
28 | * The `data-mid` prop _must_ be a literal string value - it cannot be a dynamic
29 | value, or a variable reference
30 | * The direct descendants of a Container can only be a single component type -
31 | `ContainerChild` from
32 | [Peregrine](https://github.com/magento-research/peregrine/)
33 | * A Container _must_ be a DOM element - it cannot be a Composite Component
34 |
35 | ## `ContainerChild` Details
36 |
37 | Import the `ContainerChild` component from `@magento/peregrine` to use it in
38 | your extension/module:
39 |
40 | ```js
41 | import { ContainerChild } from '@magento/peregrine';
42 | ```
43 |
44 | See the
45 | [`ContainerChild`](https://github.com/magento-research/peregrine/blob/master/docs/ContainerChild.md)
46 | documentation for further details on usage.
47 |
48 | ## Supported Operations/Configurations
49 |
50 | ### Fields
51 |
52 | | Config Name | Description |
53 | | ----------------- | :--------------------------------------------------------------------------------------: |
54 | | `operation` | One of the supported types of operations |
55 | | `targetContainer` | The `data-mid` value of the `Container` to target |
56 | | `targetChild` | The `id` value of the `ContainerChild` to target within `targetContainer` |
57 | | `componentPath` | An absolute path pointing to a file containing a React component as the `default` export |
58 |
59 | ### Operations
60 |
61 | #### removeContainer
62 |
63 | ##### Configuration
64 |
65 | ```js
66 | {
67 | "operation": "removeContainer",
68 | "targetContainer": "any.container.id"
69 | }
70 | ```
71 |
72 |
73 | Example
74 |
75 | ##### Input
76 |
77 | ```js
78 | import React from 'react';
79 |
80 | function render() {
81 | return (
82 |