Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Commit 60558dc

Browse files
committed
changes to install dxsync
1 parent de32ed3 commit 60558dc

6 files changed

Lines changed: 90 additions & 59 deletions

File tree

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = function(grunt) {
1010
files : [{
1111
expand : true,
1212
cwd : ".",
13-
src : ["install.cmd", "install.sh", "readme.md", "wcm-design.tar.gz", "dashboard.tar.gz", "dxsync-1.0.2.tar.gz", "sp-server.tar.gz", "LICENSE", "NOTICE"],
13+
src : ["install.cmd", "install.sh", "readme.md", "wcm-design.tar.gz", "dashboard.tar.gz", "sp-server.tar.gz", "LICENSE", "NOTICE"],
1414
dest : "/",
1515
filter : "isFile"
1616
}]

dashboard.tar.gz

390 Bytes
Binary file not shown.

digexp-dashboard/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"async": "^1.3.0",
2626
"chokidar": "^1.0.3",
2727
"diff": "^1.4.0",
28-
"dxsync": "https://github.com/digexp/dxsync/archive/1.0.2.tar.gz",
2928
"digexp-wcm-design": "file:../wcm-design.tar.gz",
3029
"findit": "",
3130
"map-stream": "0.0.6",

digexp-dashboard/postinstall.js

Lines changed: 89 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,107 @@
11
/*
2-
* Copyright 2015 IBM Corp.
2+
* Copyright 2015 IBM Corp.
33
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
44
* You may obtain a copy of the License at
5-
* http://www.apache.org/licenses/LICENSE-2.0
6-
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
7-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
5+
* http://www.apache.org/licenses/LICENSE-2.0
6+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
7+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
88
* specific language governing permissions and limitations under the License.
99
*/
1010
var fs = require("fs");
1111
var ch = require("child_process");
1212
var path = require("path");
1313
var async = require("async");
14-
1514
var rm_rf = function(path, cb) {
16-
fs.stat(path, function(err, stats) {
17-
if (err) {
18-
cb && cb(err);
19-
} else if (stats.isDirectory()) {
20-
fs.readdir(path, function(err, files) {
15+
fs.stat(path, function(err, stats) {
2116
if (err) {
22-
cb && cb(err);
17+
cb && cb(err);
18+
} else if (stats.isDirectory()) {
19+
fs.readdir(path, function(err, files) {
20+
if (err) {
21+
cb && cb(err);
22+
} else {
23+
async.parallel(files.map(function(file) {
24+
// delete each file
25+
return function(cb) {
26+
rm_rf(path + "/" + file, cb);
27+
};
28+
}), function() {
29+
// then delete the directory
30+
fs.rmdir(path, function(err) {
31+
cb && cb(err);
32+
});
33+
});
34+
}
35+
});
2336
} else {
24-
async.parallel(files.map(function(file) {
25-
// delete each file
26-
return function(cb) {
27-
rm_rf(path + "/" + file, cb);
28-
}
29-
}), function() {
30-
// then delete the directory
31-
fs.rmdir(path, function(err) {
32-
cb && cb(err);
37+
fs.unlink(path, function(err) {
38+
cb && cb(err);
3339
});
34-
});
3540
}
36-
});
37-
} else {
38-
fs.unlink(path, function(err) {
39-
cb && cb(err);
40-
});
41-
}
42-
})
41+
});
4342
};
44-
4543
console.log("Installing dxsync:");
46-
47-
ch.exec("npm install https://github.com/OpenNTF/WebDevToolkitForDx/blob/master/dxsync-1.0.2.tar?raw=true --no-optional",
48-
function(err) {
49-
if (err) {
50-
console.error("Error installing dxsync: " + err.message);
51-
} else {
52-
rm_rf("node_modules/dxsync/precompiled_modules/");
53-
rm_rf("node_modules/dxsync/precompiled_modules.zip");
54-
55-
setTimeout(function() {
56-
console.log("Done!")
57-
}, 300);
58-
}
59-
});
60-
44+
var cwd = process.cwd();
45+
var command = "npm install --no-optional --no-bin-links --prefix " + cwd + " https://github.com/OpenNTF/WebDevToolkitForDx/blob/master/dxsync-1.0.2.tar.gz?raw=true";
46+
if (process.platform == "win32") {
47+
command = "https://github.com/OpenNTF/WebDevToolkitForDx/blob/master/dxsync-1.0.2.tar.gz?raw=true";
48+
};
49+
var cleanup = function() {
50+
rm_rf("node_modules/dxsync/precompiled_modules/");
51+
rm_rf("node_modules/dxsync/precompiled_modules.zip");
52+
};
53+
var cleanupWindows = function(cb) {
54+
ch.exec("npm root -g", { }, function(err, root) {
55+
root = root || process.env._;
56+
if (root && fs.existsSync(root + "\\dxsync\\package.json")) {
57+
ch.exec('xcopy "' + root + '\\dxsync" "' + process.cwd() + '\\node_modules\\dxsync" /e /y', function() {
58+
cb && cb();
59+
});
60+
} else {
61+
cb && cb();
62+
}
63+
});
64+
};
65+
var cleanupUnix = function(cb) {
66+
if (fs.existsSync("lib/node_modules/dxsync/package.json")) {
67+
ch.exec("cp -r lib/node_modules/dxsync/ node_modules/dxsync/", function() {
68+
rm_rf("lib/node_modules/dxsync");
69+
// ./lib/ shouldn't exist in this version of npm
70+
cb && cb();
71+
});
72+
};
73+
};
74+
cleanup();
75+
/*ch.exec(command, { cwd: cwd },
76+
function(err, stdout, stderr) {
77+
if (stdout) {
78+
console.log(stdout);
79+
}
80+
if (stderr) {
81+
console.error(stderr);
82+
}
83+
if (err) {
84+
console.error("Error installing dxsync: " + err.message);
85+
} else if (process.platform == "win32") {
86+
cleanupWindows(cleanup);
87+
} else {
88+
cleanupUnix(cleanup);
89+
}
90+
setTimeout(function() {
91+
console.log("Done!")
92+
}, 500);
93+
});*/
6194
// check if user-settings has been saved temporarily
6295
// (for saving settings when re-installing the dashboard globally)
63-
ch.exec("npm root -g", function(err, root) {
64-
if (root) {
65-
root = root.replace(/\n|\r/g, "");
66-
fs.readFile(path.resolve(root, ".digexp-dashboard-user-settings.json"),
67-
function(err, contents) {
68-
if (!err) {
69-
fs.writeFile(path.resolve(root, "digexp-dashboard/user-settings.json"),
70-
contents);
71-
fs.unlink(path.resolve(root, ".digexp-dashboard-user-settings.json"))
72-
}
73-
});
74-
}
75-
});
96+
ch.exec("npm root -g", { }, function(err, root) {
97+
root = root || process.env._;
98+
if (root) {
99+
root = root.replace(/\n|\r/g, "");
100+
fs.readFile(path.resolve(root, ".digexp-dashboard-user-settings.json"), function(err, contents) {
101+
if (!err) {
102+
fs.writeFile(path.resolve(root, "digexp-dashboard/user-settings.json"), contents);
103+
fs.unlink(path.resolve(root, ".digexp-dashboard-user-settings.json"))
104+
}
105+
});
106+
}
107+
});

sp-server.tar.gz

0 Bytes
Binary file not shown.

wcm-design.tar.gz

6 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)