Skip to content

Commit ae096b1

Browse files
committed
Remove MySQL and convert setup/restore scripts to grunt tasks.
1 parent 4dcfe2e commit ae096b1

File tree

10 files changed

+135
-679
lines changed

10 files changed

+135
-679
lines changed

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Simply add a [post-receive hook](http://help.github.com/post-receive-hooks/) to
2727

2828
#### HOSTS
2929

30-
1. Add a `plugins.jquery.com.dev` entry in /etc/hosts
30+
1. Add a `dev.plugins.jquery.com` entry in /etc/hosts
3131

32-
* `127.0.0.1 plugins.jquery.com.dev`
32+
* `127.0.0.1 dev.plugins.jquery.com`
3333

3434
#### web-base-template
3535

@@ -46,15 +46,15 @@ Simply add a [post-receive hook](http://help.github.com/post-receive-hooks/) to
4646
3. Move `wordpress/wp-config.php` to `wp-config.php` and add the following:
4747

4848
define( 'WP_CONTENT_DIR', dirname( ABSPATH ) . '/web-base-template' );
49-
define( 'WP_CONTENT_URL', 'http://plugins.jquery.com.dev/web-base-template' );
49+
define( 'WP_CONTENT_URL', 'http://dev.plugins.jquery.com/web-base-template' );
5050

5151
4. Copy `wordpress/index.php` to `index.php` and add update the require at the bottom to be:
5252

5353
require('./wordpress/wp-blog-header.php');
5454

5555
#### WordPress config
5656

57-
From http://plugins.jquery.com.dev/wordpress/wp-admin/
57+
From http://dev.plugins.jquery.com/wordpress/wp-admin/
5858

5959
1. Update Site Address
6060

@@ -88,13 +88,10 @@ From http://plugins.jquery.com.dev/wordpress/wp-admin/
8888
4. `cp config-sample.json config.json`
8989

9090
5. Edit config.json
91-
* Set `dbName` to your WordPress MySQL database name
92-
* Set `dbUser` to your WordPress MySQL database user
93-
* Set `dbPassword` to your WordPress MySQL database password
94-
* Leave `siteId` null (unless you happen to be using a Wordpress multi-site installation locally, in which case supply the site's ID in the multi-site install)
91+
* Set `wordpress` properties to contain a valid username and password for the WordPress site.
9592

96-
6. `node src/setup.js`
97-
* This is a one time setup which will erase any previous data generated by other scripts in this repo.
93+
6. `grunt setup`
94+
* This is a one time setup.
9895

9996
7. `node src/update.js`
10097
* This expects a post-receive hook as stdin. You can use `{"repository":{"url":"http://github.com/scottgonzalez/temp-jquery-foo","watchers":3,"forks":25}}` for testing.

config-sample.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,4 @@
66
"user": "admin",
77
"password": "secret"
88
}
9-
10-
"dbHost": "localhost",
11-
"dbPort": 3306,
12-
"dbName": "mysql",
13-
"dbUser": "mysql",
14-
"dbPassword": "secret",
15-
"siteId": null
169
}

grunt.js

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

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
"type": "git",
99
"url": "git://github.com/jquery/plugins.jquery.com.git"
1010
},
11-
"main": "./src/main.js",
1211
"dependencies": {
1312
"mkdirp": "0.2.1",
14-
"mysql": "0.9.5",
1513
"semver": "1.0.12",
1614
"sqlite3": "2.1.1",
1715
"step": "0.0.5",
1816
"rimraf": "1.0.9",
1917
"node-syslog": "1.1.1",
20-
"wordpress": "0.1.1"
18+
"wordpress": "0.1.1",
19+
"grunt": "0.3.9",
20+
"grunt-wordpress": "0.1.1"
2121
},
2222
"engines": {
2323
"node": "0.6.5"
2424
}
25-
}
25+
}

pages/names renamed to site-content/page/names.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Naming Your Plugin
1+
<script>{
2+
"title": "Naming Your Plugin"
3+
}</script>
24

35
<p>Before you can list your plugin on this site, you'll need to choose a name for your plugin. The name is a unique identifier that distinguishes your plugin from all other plugins. This is different from the title of your plugin, which you can think of as the display name.</p>
46

0 commit comments

Comments
 (0)