Skip to content

Commit 1157c07

Browse files
author
Ahmad Awais
committed
📦 NEW: Update Notifier
1 parent b21b55e commit 1157c07

9 files changed

Lines changed: 103 additions & 27 deletions

File tree

packages/babel-preset-cgb/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
/**
22
* Basically the .babelrc file.
33
*/
4+
5+
// Update notifier.
6+
const updateNotifier = require( 'update-notifier' );
7+
const pkg = require( './package.json' );
8+
const notifier = updateNotifier( {
9+
pkg: pkg,
10+
// updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day.
11+
} );
12+
13+
if ( notifier.update ) {
14+
notifier.notify();
15+
process.exit( 0 );
16+
}
17+
418
module.exports = {
519
presets: [
620
[
Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
{
2-
"name": "babel-preset-cgb",
3-
"version": "0.0.5",
4-
"description": "Babel preset used by Create Guten Block",
5-
"repository": "ahmadawais/create-guten-block",
6-
"license": "MIT",
7-
"bugs": {
8-
"url": "https://github.com/ahmadawais/create-guten-block/issues"
9-
},
10-
"files": [
11-
"index.js"
12-
],
13-
"dependencies": {
14-
"babel-plugin-transform-class-properties": "6.24.1",
15-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
16-
"babel-plugin-transform-react-jsx": "^6.24.1",
17-
"babel-plugin-transform-runtime": "^6.23.0",
18-
"babel-preset-env": "^1.6.0"
19-
}
2+
"name": "babel-preset-cgb",
3+
"version": "0.0.5",
4+
"description": "Babel preset used by Create Guten Block",
5+
"repository": "ahmadawais/create-guten-block",
6+
"license": "MIT",
7+
"bugs": {
8+
"url": "https://github.com/ahmadawais/create-guten-block/issues"
9+
},
10+
"files": ["index.js"],
11+
"dependencies": {
12+
"babel-plugin-transform-class-properties": "6.24.1",
13+
"babel-plugin-transform-object-rest-spread": "^6.26.0",
14+
"babel-plugin-transform-react-jsx": "^6.24.1",
15+
"babel-plugin-transform-runtime": "^6.23.0",
16+
"babel-preset-env": "^1.6.0",
17+
"update-notifier": "^2.3.0"
18+
}
2019
}

packages/cgb-dev-utils/clearConsole.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88

99
'use strict';
1010

11+
// Update notifier.
12+
const updateNotifier = require( 'update-notifier' );
13+
const pkg = require( './package.json' );
14+
const notifier = updateNotifier( {
15+
pkg: pkg,
16+
// updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day
17+
} );
18+
19+
if ( notifier.update ) {
20+
notifier.notify();
21+
process.exit( 0 );
22+
}
23+
1124
/**
1225
* Cross platform clear console.
1326
*/

packages/cgb-dev-utils/crossSpawn.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77

88
'use strict';
99

10+
// Update notifier.
11+
const updateNotifier = require( 'update-notifier' );
12+
const pkg = require( './package.json' );
13+
const notifier = updateNotifier( {
14+
pkg: pkg,
15+
updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day.
16+
} );
17+
18+
if ( notifier.update ) {
19+
notifier.notify();
20+
process.exit( 0 );
21+
}
22+
1023
const crossSpawn = require( 'cross-spawn' );
1124

1225
module.exports = crossSpawn;

packages/cgb-dev-utils/formatWebpackMessages.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77

88
'use strict';
99

10+
// Update notifier.
11+
const updateNotifier = require( 'update-notifier' );
12+
const pkg = require( './package.json' );
13+
const notifier = updateNotifier( {
14+
pkg: pkg,
15+
updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day.
16+
} );
17+
18+
if ( notifier.update ) {
19+
notifier.notify();
20+
process.exit( 0 );
21+
}
22+
1023
// WARNING: this code is untranspiled and is used in browser too.
1124
// Please make sure any changes are in ES5 or contribute a Babel compile step.
1225

packages/cgb-dev-utils/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"dependencies": {
1414
"chalk": "2.3.0",
15-
"cross-spawn": "5.1.0"
15+
"cross-spawn": "5.1.0",
16+
"update-notifier": "^2.3.0"
1617
}
1718
}

packages/cgb-scripts/bin/cgb-scripts.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
#!/usr/bin/env node
22
'use strict';
33

4+
// Update notifier.
5+
const updateNotifier = require( 'update-notifier' );
6+
const pkg = require( './package.json' );
7+
const notifier = updateNotifier( {
8+
pkg: pkg,
9+
// updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day.
10+
} );
11+
12+
if ( notifier.update ) {
13+
notifier.notify();
14+
process.exit( 0 );
15+
}
16+
417
const spawn = require( 'cgb-dev-utils/crossSpawn' );
518
const args = process.argv.slice( 2 );
619

packages/cgb-scripts/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"resolve-pkg": "^1.0.0",
4242
"sass-loader": "^6.0.6",
4343
"style-loader": "^0.19.1",
44+
"update-notifier": "^2.3.0",
45+
4446
"webpack": "^3.1.0"
4547
}
4648
}

packages/create-guten-block/createGutenBlock.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
#!/usr/bin/env node
22
// create-guten-block CLI!
3-
const shell = require( 'shelljs' );
4-
const updateNotifier = require( 'update-notifier' );
5-
const execa = require( 'execa' );
63
const ora = require( 'ora' );
74
const chalk = require( 'chalk' );
8-
const pkg = require( './package.json' );
5+
const execa = require( 'execa' );
6+
const shell = require( 'shelljs' );
97
const resolvePkg = require( 'resolve-pkg' );
108
const template = resolvePkg( 'cgb-scripts/template', { cwd: __dirname } );
119
const directoryExists = require( 'directory-exists' );
1210

11+
// Update notifier.
12+
const updateNotifier = require( 'update-notifier' );
13+
const pkg = require( './package.json' );
14+
const notifier = updateNotifier( {
15+
pkg: pkg,
16+
updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day.
17+
} );
18+
19+
if ( notifier.update ) {
20+
notifier.notify();
21+
process.exit( 0 );
22+
}
23+
1324
/**
1425
* Cross platform clear console.
1526
*/
@@ -19,10 +30,7 @@ function clearConsole() {
1930
);
2031
}
2132

22-
console.log( template );
23-
24-
// Update notifier.
25-
updateNotifier( { pkg } ).notify();
33+
// console.log( template );
2634

2735
// Is there a plugin-name provided as the third argument?
2836
const theThirdArgument = process.argv[ 2 ];

0 commit comments

Comments
 (0)