@@ -4,11 +4,8 @@ import fs from 'fs-extra';
44import babel from 'gulp-babel' ;
55import sourcemaps from 'gulp-sourcemaps' ;
66import execa from 'execa' ;
7- import transformLoader from '@ringcentral-integration/locale-loader/lib/transformLoader' ;
8- import exportLocale from '@ringcentral-integration/locale-loader/lib/exportLocale' ;
9- import importLocale from '@ringcentral-integration/locale-loader/lib/importLocale' ;
10- import consolidateLocale from '@ringcentral-integration/locale-loader/lib/consolidateLocale' ;
11- import localeSettings from 'locale-settings' ;
7+ import * as localeLoader from '@ringcentral-integration/locale-loader' ;
8+ import localeSettings from '@ringcentral-integration/locale-settings' ;
129
1310async function getVersionFromTag ( ) {
1411 let tag = process . env . TRAVIS_TAG ;
@@ -28,57 +25,60 @@ async function getVersionFromTag() {
2825}
2926
3027const BUILD_PATH = path . resolve ( __dirname , '../../build/glip-widgets' ) ;
31- gulp . task ( 'clean' , async ( ) => (
32- fs . remove ( BUILD_PATH )
33- ) ) ;
3428
35- gulp . task ( 'build' , [ 'clean' , 'copy' ] , ( ) => (
36- gulp . src ( [
29+ export function clean ( ) {
30+ return fs . remove ( BUILD_PATH ) ;
31+ }
32+ export function copy ( ) {
33+ return gulp . src ( [
34+ './**' ,
35+ '!./**/*.js' ,
36+ '!./test{/**,}' ,
37+ '!./coverage{/**,}' ,
38+ '!./node_modules{/**,}' ,
39+ '!package-lock.json'
40+ ] ) . pipe ( gulp . dest ( BUILD_PATH ) )
41+ }
42+ export function compile ( ) {
43+ return gulp . src ( [
3744 './**/*.js' ,
3845 '!./**/*.test.js' ,
3946 '!./coverage{/**,}' ,
4047 '!./node_modules{/**,}' ,
4148 '!gulpfile.babel.js' ]
42- ) . pipe ( transformLoader ( {
49+ ) . pipe ( localeLoader . transformLoader ( {
4350 ...localeSettings ,
4451 } ) )
4552 . pipe ( sourcemaps . init ( ) )
4653 . pipe ( babel ( ) )
4754 . pipe ( sourcemaps . write ( '.' ) )
48- . pipe ( gulp . dest ( BUILD_PATH ) )
49- ) ) ;
55+ . pipe ( gulp . dest ( BUILD_PATH ) ) ;
56+ }
5057
51- gulp . task ( 'copy' , [ 'clean' ] , ( ) => (
52- gulp . src ( [
53- './**' ,
54- '!./**/*.js' ,
55- '!./test{/**,}' ,
56- '!./coverage{/**,}' ,
57- '!./node_modules{/**,}' ,
58- '!package-lock.json'
59- ] ) . pipe ( gulp . dest ( BUILD_PATH ) )
60- ) ) ;
58+
59+ export const build = gulp . series ( clean , gulp . parallel ( copy , compile ) ) ;
6160
6261const RELEASE_PATH = path . resolve ( __dirname , '../../release/glip-widgets' ) ;
63- gulp . task ( 'release-clean' , async ( ) => {
62+
63+ export async function releaseClean ( ) {
6464 if ( ! await fs . exists ( RELEASE_PATH ) ) {
6565 await execa . shell ( `mkdir -p ${ RELEASE_PATH } ` ) ;
6666 }
6767 const files = ( await fs . readdir ( RELEASE_PATH ) ) . filter ( file => ! / ^ \. / . test ( file ) ) ;
6868 for ( const file of files ) {
6969 await fs . remove ( path . resolve ( RELEASE_PATH , file ) ) ;
7070 }
71- } ) ;
71+ }
7272
73- gulp . task ( 'release-copy' , [ 'build' , 'release-clean' ] , ( ) => (
74- gulp . src ( [
73+ export function releaseCopy ( ) {
74+ return gulp . src ( [
7575 `${ BUILD_PATH } /**` ,
7676 `${ __dirname } /README.md` ,
7777 `${ __dirname } /LICENSE`
78- ] ) . pipe ( gulp . dest ( RELEASE_PATH ) )
79- ) ) ;
78+ ] ) . pipe ( gulp . dest ( RELEASE_PATH ) ) ;
79+ }
8080
81- gulp . task ( 'release' , [ 'release-copy' ] , async ( ) => {
81+ export async function generatePackage ( ) {
8282 const packageInfo = JSON . parse ( await fs . readFile ( path . resolve ( BUILD_PATH , 'package.json' ) ) ) ;
8383 delete packageInfo . scripts ;
8484 delete packageInfo . jest ;
@@ -89,23 +89,39 @@ gulp.task('release', ['release-copy'], async () => {
8989 packageInfo . name = 'ringcentral-widgets' ;
9090 }
9191 await fs . writeFile ( path . resolve ( RELEASE_PATH , 'package.json' ) , JSON . stringify ( packageInfo , null , 2 ) ) ;
92- } ) ;
92+ }
9393
94- gulp . task ( 'export-locale' , ( ) => exportLocale ( {
95- ...localeSettings ,
96- } ) ) ;
97- gulp . task ( 'export-locale-full' , ( ) => exportLocale ( {
98- ...localeSettings ,
99- exportType : 'full'
100- } ) ) ;
101- gulp . task ( 'export-locale-translated' , ( ) => exportLocale ( {
102- ...localeSettings ,
103- exportType : 'translated'
104- } ) ) ;
105- gulp . task ( 'import-locale' , ( ) => importLocale ( {
106- ...localeSettings ,
107- } ) ) ;
108- gulp . task ( 'consolidate-locale' , ( ) => consolidateLocale ( {
109- ...localeSettings ,
110- sourceFolder : path . resolve ( __dirname , 'lib/countryNames' ) ,
111- } ) ) ;
94+ export const release = gulp . series (
95+ gulp . parallel ( build , releaseClean ) ,
96+ gulp . parallel ( releaseCopy , generatePackage ) ,
97+ ) ;
98+
99+ export function exportLocale ( ) {
100+ return localeLoader . exportLocale ( {
101+ ...localeSettings ,
102+ } ) ;
103+ }
104+ export function exportFullLocale ( ) {
105+ return localeLoader . exportLocale ( {
106+ ...localeSettings ,
107+ exportType : 'full' ,
108+ } ) ;
109+ }
110+
111+ export function exportTranslatedLocale ( ) {
112+ return localeLoader . exportLocale ( {
113+ ...localeSettings ,
114+ exportType : 'translated'
115+ } ) ;
116+ }
117+ export function importLocale ( ) {
118+ return localeLoader . importLocale ( {
119+ ...localeSettings ,
120+ } ) ;
121+ }
122+ export function consolidateLocale ( ) {
123+ return localeLoader . consolidateLocale ( {
124+ ...localeSettings ,
125+ sourceFolder : path . resolve ( __dirname , 'lib/countryNames' ) ,
126+ } ) ;
127+ }
0 commit comments