forked from jquery-archive/plugins.jquery.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grunt.js
116 lines (92 loc) · 2.55 KB
/
grunt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
var config = require( "./lib/config" );
module.exports = function( grunt ) {
grunt.loadNpmTasks( "grunt-wordpress" );
grunt.initConfig({
lint: {
grunt: "grunt.js",
src: [ "lib/**", "scripts/**" ]
},
test: {
files: [ "test/**/*.js" ]
},
wordpress: config.wordpress
});
// We only want to sync the documentation, so we override wordpress-get-postpaths
// to only find pages. This ensures that we don't delete all of the plugin posts.
grunt.registerHelper( "wordpress-get-postpaths", function( fn ) {
var client = grunt.helper( "wordpress-client" );
grunt.verbose.write( "Getting post paths from WordPress..." );
client.call( "gw.getPostPaths", "page", function( error, postPaths ) {
if ( error ) {
grunt.verbose.error();
return fn( error );
}
grunt.verbose.ok();
grunt.verbose.writeln();
fn( null, postPaths );
});
});
grunt.registerTask( "docs", function() {
var done = this.async();
grunt.helper( "wordpress-sync-posts", "site-content/", function( error ) {
if ( error ) {
done( false );
}
done();
});
});
grunt.registerTask( "clean-all", function() {
var rimraf = require( "rimraf" ),
retry = require( "./lib/retrydb" );
// clean repo checkouts
rimraf.sync( config.repoDir );
// clean pluginsDb
rimraf.sync( config.pluginsDb );
rimraf.sync( "last-action" );
// clean retrydb
rimraf.sync( retry.dbPath );
});
grunt.registerTask( "clean", function() {
var rimraf = require( "rimraf" ),
retry = require( "./lib/retrydb" );
rimraf.sync( "last-action" );
rimraf.sync( retry.dbPath );
});
grunt.registerTask( "setup-pluginsdb", function() {
var done = this.async();
require( "./lib/pluginsdb" )._setup(function( error ) {
if ( error ) {
return done( false );
}
done();
});
});
grunt.registerTask( "setup-retrydb", function() {
var done = this.async();
require( "./lib/retrydb" )._setup(function( error ) {
if ( error ) {
return done( false );
}
done();
});
});
grunt.registerTask( "restore-repos", function() {
var service = require( "./lib/service" ),
pluginsDb = require( "./lib/pluginsdb" ),
done = this.async();
pluginsDb.getAllRepos(function( error, repos ) {
grunt.utils.async.mapSeries( repos, function( repo, fn ) {
service.getRepoById( repo ).restore( fn );
}, function( error ) {
if ( error ) {
return done( false );
}
done();
});
});
});
grunt.registerTask( "default", "lint test" );
grunt.registerTask( "setup", "setup-pluginsdb setup-retrydb docs" );
grunt.registerTask( "update", "docs" );
grunt.registerTask( "restore", "clean setup-retrydb docs restore-repos" );
};