Skip to content

Commit

Permalink
Build: Move date module to packages maintained by Lerna (#6658)
Browse files Browse the repository at this point in the history
* Framework: Move date module to packages maintained by Lerna

* Move source code to src subfolder for date package

* Date: Revert code that uses `date` modules instead of `moment`

* Build: Update Webpack config

* Build: Fix entry point for Gutenberg packages

* Avoid global usage in the date module making it npm ready

* Chore: Do some cleanup for obsolete code

* Docs: Copy releasing packages manual from packages repository

* Build: Use independent versioning for packages

* Date: Add footer image to the Readme file
  • Loading branch information
gziolo authored May 11, 2018
1 parent 7fb242b commit d70ec18
Show file tree
Hide file tree
Showing 15 changed files with 1,966 additions and 214 deletions.
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"
}
},
"packages": [
"packages/*"
],
"version": "independent"
}
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

0 comments on commit d70ec18

Please sign in to comment.