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

Spec Parser: Move generated spec parser to package #13493

Merged
merged 3 commits into from
Jan 25, 2019

Conversation

aduth
Copy link
Member

@aduth aduth commented Jan 24, 2019

This pull request seeks to treat lib/parser.php as a generated build artifact of the block-serialization-spec-parser package, both removing it from lib/ and from source altogether, assumed to be generated as part of npm run build in time for a package publish. This treatment has been applied to the parser.js generated result as well.

Testing instructions:

lib/parser.php is not actually used by Gutenberg, so it should have no impact on the effective behavior of the plugin.

Verify that parser.js and parser.php are generated to packages/block-serialization-spec-parser after npm install.

Ensure that tests pass covering the generated files:

npm run test-unit packages/block-serialization-spec-parser

@aduth aduth added the [Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f label Jan 24, 2019
@aduth aduth requested a review from dmsnell January 24, 2019 21:31
@@ -21,16 +21,6 @@ fi

npm run build || exit 1

# Make sure phpegjs parser is up to date
node bin/create-php-parser.js || exit 1
if ! git diff --quiet --exit-code lib/parser.php; then
Copy link
Member Author

Choose a reason for hiding this comment

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

This check is already accounted for in CI by:

  • The files are automatically built as a postinstall step
  • CI runs check-local-changes to verify no commit-able files

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@dmsnell dmsnell left a comment

Choose a reason for hiding this comment

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

Thanks @aduth! This seems like a good improvement on code organization and reducing noise in the repo.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Yes, this is all good. As long as those files land on npm they can be ingored from git repository.

Very nice refactor.

@@ -21,16 +21,6 @@ fi

npm run build || exit 1

# Make sure phpegjs parser is up to date
node bin/create-php-parser.js || exit 1
if ! git diff --quiet --exit-code lib/parser.php; then
Copy link
Member

Choose a reason for hiding this comment

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

👍

@gziolo gziolo added this to the 5.0 (Gutenberg) milestone Jan 25, 2019
@aduth
Copy link
Member Author

aduth commented Jan 25, 2019

As long as those files land on npm they can be ingored from git repository.

I think this might not actually be working as expected yet. I learned recently that apparently npm will inherit a gitignore when there's no other whitelist / blacklist. I tracked it down to:

If there is a .gitignore file, and .npmignore is missing, .gitignore’s contents will be used instead.

https://docs.npmjs.com/files/package.json#files

Indeed, running npm pack && tar -tf wordpress-block-serialization-spec-parser-2.0.3.tgz reveals there is no parser.js nor parser.php.

We could define files, or alternatively just add an empty .npmignore. I'll see which works better.

@aduth
Copy link
Member Author

aduth commented Jan 25, 2019

Started with a whitelist, but apparently some of the main exports of the package include tests, so switched to an empty .npmignore instead, which appears to work well.

@gziolo
Copy link
Member

gziolo commented Jan 25, 2019

Thanks for exploring it further. I took it by surprise that it works this way. It should be okey to proceed as is 💯

@mcsf
Copy link
Contributor

mcsf commented Jan 25, 2019

Thanks for this!

@aduth aduth merged commit ef1c0e8 into master Jan 25, 2019
@aduth aduth deleted the move/generated-spec-parser branch January 25, 2019 16:31
daniloercoli added a commit that referenced this pull request Jan 26, 2019
…rnmobile/372-enter-key-detection-to-title

* 'master' of https://github.com/WordPress/gutenberg: (29 commits)
  Update for RangeControl documentation (#12564)
  Plugin: Deprecate gutenberg_load_list_reusable_blocks (#13456)
  Update the columns attribute in onSelectImages so that if images are removed via the media modal, the columns can't be higher than the new number of images (#13488)
  Replace the fullscreen "exit" icon with a back arrow (#13403)
  Include :visited links in button color (#12183)
  Amazon Kindle block (#13510)
  Plugin: Deprecate gutenberg_prepare_blocks_for_js (#13457)
  Add watcher on Linux: change fs to node-watch (#13448)
  Plugin: Deprecate `gutenberg` theme support (#13458)
  Datepicker: Add inValidDay support (#12962)
  Block Switcher: Render disabled button even if multi-selection (#13431)
  Plugin: Deprecate gutenberg_register_post_types (#13468)
  Plugin: Deprecate register_tinymce_scripts (#13466)
  Set minimum of words for RSS excerpt (#13502)
  Plugin: Deprecate gutenberg_get_block_categories (#13454)
  Plugin: Deprecate gutenberg_content_block_version (#13469)
  API Fetch: Expose nonce on created middleware function (#13451)
  Plugin: Remove list screens integrations (#13459)
  Plugin: Remove core-defined block detection functions (#13467)
  Spec Parser: Move generated spec parser to package (#13493)
  ...
youknowriad pushed a commit that referenced this pull request Mar 6, 2019
* Spec Parser: Move generated spec parser to package

* Spec Parser: Add empty npmignore

* Spec Parser: Add CHANGELOG entry
youknowriad pushed a commit that referenced this pull request Mar 6, 2019
* Spec Parser: Move generated spec parser to package

* Spec Parser: Add empty npmignore

* Spec Parser: Add CHANGELOG entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants