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

Build: Move date module to packages maintained by Lerna #6658

Merged
merged 10 commits into from
May 11, 2018
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,46 @@ The workflow is documented in greater detail in the [repository management](./do

Gutenberg contains both PHP and JavaScript code, and encourages testing and code style linting for both. It also incorporates end-to-end testing using [Google Puppeteer](https://developers.google.com/web/tools/puppeteer/). You can find out more details in [Testing Overview document](./docs/reference/testing-overview.md).

## Releasing packages

This repository uses [lerna](https://lernajs.io) to manage Gutenberg modules and publish them as packages to `npm`. Lerna automatically releases all the outdated packages. To check which packages are outdated and will be released, type `npm run publish:check`.

If you have the ability to publish packages, you _must_ have [2FA enabled](https://docs.npmjs.com/getting-started/using-two-factor-authentication) on your npmjs.com account.

### Before releasing

Confirm that you're logged into `npm`, by running `npm whoami`. If you're not logged in, run `npm adduser` to login.

If you're publishing a new package, ensure that its `package.json` file contains the correct `publishConfig` settings:

```json
"publishConfig": {
"access": "public"
}
```

### Development release

Run the following command to release a dev version of the outdated packages, replacing "123456" with your 2FA code. Make sure you're using a freshly generated 2FA code, rather than one that's about to timeout. This is a little cumbersome, but helps to prevent the release process from dying mid-deploy.

```bash
NPM_CONFIG_OTP=123456 npm run publish:dev
```

Lerna will ask you which version number you want to choose for each package. For a `dev` release, you'll more likely want to choose the "prerelease" option. Repeat the same for all the outdated packages and confirm your version updates.

Lerna will then publish to `npm`, commit the `package.json` changes and create the git tags.

### Production release

To release a production version for the outdated packages, run the following command, replacing "123456" with your (freshly generated, as above) 2FA code:

```bash
NPM_CONFIG_OTP=123456 npm run publish:prod
```

Choose the correct version (minor, major or patch) and confirm your choices and let Lerna do its magic.

## How Designers Can Contribute

If you'd like to contribute to the design or front-end, feel free to contribute to tickets labelled <a href="https://github.com/WordPress/gutenberg/issues?q=is%3Aissue+is%3Aopen+label%3ADesign">Design</a>. We could use your thoughtful replies, mockups, animatics, sketches, doodles. Proposed changes are best done as minimal and specific iterations on the work that precedes it so we can compare. If you use <a href="https://www.sketchapp.com/">Sketch</a>, you can grab <a href="https://cloudup.com/cMPXM8Va2cy">the source file for the mockups</a> (updated April 6th).
Expand Down
4 changes: 3 additions & 1 deletion components/date-time/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ Render a DateTimePicker.

```jsx
import { DateTimePicker } from '@wordpress/components';
import { settings } from '@wordpress/date';
import { getSettings } from '@wordpress/date';

function selectTime( date, onUpdateDate ) {
const settings = getSettings();

// To know if the current timezone is a 12 hour time with look for "a" in the time format.
// We also make sure this a is not escaped by a "/".
const is12HourTime = /a(?!\\)/i.test(
Expand Down
3 changes: 2 additions & 1 deletion editor/components/post-schedule/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { settings } from '@wordpress/date';
import { getSettings } from '@wordpress/date';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/element';

Expand All @@ -11,6 +11,7 @@ import { compose } from '@wordpress/element';
import { DateTimePicker } from '@wordpress/components';

export function PostSchedule( { date, onUpdateDate } ) {
const settings = getSettings();
// To know if the current timezone is a 12 hour time with look for "a" in the time format
// We also make sure this a is not escaped by a "/"
const is12HourTime = /a(?!\\)/i.test(
Expand Down
3 changes: 2 additions & 1 deletion editor/components/post-schedule/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { dateI18n, settings } from '@wordpress/date';
import { dateI18n, getSettings } from '@wordpress/date';
import { withSelect } from '@wordpress/data';

function PostScheduleLabel( { date } ) {
const settings = getSettings();
return date ?
dateI18n( settings.formats.datetime, date ) :
__( 'Immediately' );
Expand Down
12 changes: 12 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"lerna": "2.11.0",
"commands": {
"publish": {
"message": "chore(release): publish %s"
Copy link
Member

Choose a reason for hiding this comment

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

If the packages are going to be independently released as they are currently with the packages repo the %s here will be ignored and should be dropped here, see https://github.com/lerna/lerna#--message--m-msg

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought we keep one version aligned with Gutenberg release version. I need to collect all my thoughts and move to description :)
So the idea I had is that every time we publish a new version of the plugin to .org, we publish also the same version of npm packages. We will have to revisit after 5.0 mission is accomplished.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, makes sense 👍

On the %s issue, did you run lerna init with the --independent flag? If so %s will be ignored, I'll take a closer look tomorrow, its a pretty minor thing that we will see if it is or is not when lerna publish is run for th first time 😏

Copy link
Member Author

Choose a reason for hiding this comment

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

lerna init only :)

}
},
"packages": [
"packages/*"
],
"version": "independent"
Copy link
Member

Choose a reason for hiding this comment

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

👍

}
6 changes: 3 additions & 3 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function gutenberg_register_scripts_and_styles() {
true
);
global $wp_locale;
wp_add_inline_script( 'wp-date', 'window._wpDateSettings = ' . wp_json_encode( array(
wp_add_inline_script( 'wp-date', sprintf( 'wp.date.setSettings( %s );', wp_json_encode( array(
'l10n' => array(
'locale' => get_user_locale(),
'months' => array_values( $wp_locale->month ),
Expand All @@ -168,7 +168,7 @@ function gutenberg_register_scripts_and_styles() {
'offset' => get_option( 'gmt_offset', 0 ),
'string' => get_option( 'timezone_string', 'UTC' ),
),
) ), 'before' );
) ) ), 'after' );
wp_register_script(
'wp-element',
gutenberg_url( 'build/element/index.js' ),
Expand Down Expand Up @@ -469,7 +469,7 @@ function gutenberg_register_vendor_scripts() {
$moment_script = SCRIPT_DEBUG ? 'moment.js' : 'min/moment.min.js';
gutenberg_register_vendor_script(
'moment',
'https://unpkg.com/moment@2.21.0/' . $moment_script,
'https://unpkg.com/moment@2.22.1/' . $moment_script,
array()
);
$tinymce_version = '4.7.2';
Expand Down
Loading