Skip to content

Commit 1ca67c9

Browse files
committed
Various fixes
1 parent d79c77a commit 1ca67c9

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

compile.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {execSync} = require("child_process");
1+
const {execSync, spawnSync} = require("child_process");
22
const path = require("path");
33
const process = require("process");
44
const fs = require("fs");
@@ -40,7 +40,8 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
4040
return;
4141
}
4242

43-
const header = " Creating metadata for package browser... ";
43+
const header = " Creating metadata for package browser. This will take a while. ";
44+
console.log();
4445
console.log("=".repeat(header.length));
4546
console.log(header);
4647
console.log("=".repeat(header.length));
@@ -60,7 +61,7 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
6061
this.__deleteFolderRecursiveSync(targetDir);
6162
}
6263
fs.mkdirSync(targetDir);
63-
console.log(`>>> Starting compilation of all compatible packages. This might take a while.`);
64+
console.log(`>>> Starting compilation of all compatible packages...`);
6465
let stdout = execSync(`qx pkg list --uris-only`);
6566
let packages =
6667
stdout
@@ -75,7 +76,7 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
7576
`Creating container application...`
7677
);
7778
for (let pkg of packages) {
78-
this.__addCmd(`cd ${containerPath} && qx pkg install ${pkg}`, `Installing ${pkg}...`);
79+
this.__addCmd(`qx pkg install ${pkg}`, `Installing ${pkg}...`, containerPath);
7980
}
8081
await this.__executeCommands();
8182
const packages_dir = path.join(containerPath, "qx_packages");
@@ -105,8 +106,9 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
105106
}
106107
// compile the application
107108
this.__addCmd(
108-
`cd ${pkg_dir} && qx pkg migrate && qx compile --target=${targetType} --warnAsError=false --feedback=0 --force 2>&1`,
109+
`qx pkg migrate 2>&1 && qx compile --target=${targetType} --warnAsError=false --feedback=0 --force 2>&1`,
109110
`Compiling ${manifest.info.name} v${manifest.info.version}...`,
111+
pkg_dir,
110112
(stdout, stderr) => {
111113
let compilation_log = stdout + "\n\n" +stderr;
112114
packages_data[index].data = {
@@ -121,17 +123,18 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
121123
if (targetType === "build") {
122124
this.__deleteFolderRecursiveSync(path.join(outputPath, "transpiled"));
123125
}
124-
*/
126+
*/
125127
console.log(`>>> Moving generated applications from ${outputPath} to ${appTgtPath}`);
126128
fs.renameSync(outputPath, appTgtPath);
127129
// inform client that we have one or more application demos
128130
packages_data[index].data.applications = compileData.applications;
129131
},
130132
error => {
131-
console.error(error.message);
133+
let compilation_log = error.message + "\n\n" + error.stderr.toString() + "\n\n" + error.stdout.toString();
134+
console.error(compilation_log);
132135
packages_data[index].data = {
133136
problems: true,
134-
compilation_log: error.message + "\n\n" + error.stderr.toString() + "\n\n" + error.stdout.toString()
137+
compilation_log
135138
};
136139
}
137140
);
@@ -158,29 +161,35 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
158161
* Adds a command to the command queue
159162
* @param {String} cmd The CLI command
160163
* @param {String|undefined} info An explanatory text for the log, defaults to the CLI command
161-
* @param {Function} onSuccess
164+
* @param {String|undefined} cwd
165+
* If given, the working directory in which the commands will be executed
166+
* @param {Function|undefined} onSuccess
162167
* A function that is executed when the command has succesfully terminated.
163168
* Receives the output of the command
164-
* @param {Function} onFail
169+
* @param {Function|undefined} onFail
165170
* A function that is executed when the command has finished with a non-zero
166171
* exit code or an error has been thrown in the onSuccess function. Receives
167172
* an error object.
168173
* @private
169174
*/
170-
__addCmd(cmd, info, onSuccess, onFail) {
175+
__addCmd(cmd, info, cwd, onSuccess, onFail) {
171176
this.__cmds = this.__cmds || [];
172-
this.__cmds.push([cmd, info, onSuccess, onFail]);
177+
this.__cmds.push([cmd, info, cwd, onSuccess, onFail]);
173178
},
174179

175180
/**
176181
* Executes the commands in the queue.
177182
* @private
178183
*/
179184
async __executeCommands() {
180-
for (let [cmd, info, onSuccess, onFail] of this.__cmds){
185+
for (let [cmd, info, cwd, onSuccess, onFail] of this.__cmds){
181186
console.log( ">>> " + (info || `Executing '${cmd}'`));
187+
const options = {};
188+
if (cwd) {
189+
options.cwd = cwd;
190+
}
182191
try {
183-
let stdout = execSync(cmd);
192+
let stdout = execSync(cmd, options);
184193
stdout = stdout.toString().trim();
185194
if (stdout) {
186195
console.log(stdout);

source/class/qxl/packagebrowser/PackageBrowser.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ qx.Class.define("qxl.packagebrowser.PackageBrowser", {
873873
},
874874

875875
__getNewIssueUrl(uri, newIssue=false) {
876+
uri = uri.split("/").slice(0,2).join("/");
876877
return `https://github.com/${uri}/issues${newIssue ? "/new" : ""}`;
877878
},
878879

@@ -882,7 +883,7 @@ qx.Class.define("qxl.packagebrowser.PackageBrowser", {
882883
* @private
883884
*/
884885
__getProblemsHtml(modelNode) {
885-
let {data:{compilation_log}, manifest:{info, requires}} = modelNode;
886+
let {data:{compilation_log}, manifest:{info, requires={}}} = modelNode;
886887
const lineStartsWith = [
887888
"One or more libraries",
888889
"Writing",
@@ -931,7 +932,7 @@ qx.Class.define("qxl.packagebrowser.PackageBrowser", {
931932
{
932933
regex: /^([^:]+): (.+) Unresolved use of symbol (.+)$/,
933934
description:
934-
`The compiler cannot find a reference for the given symbol '$3'.
935+
`The compiler cannot find a reference for the given symbol <span class="code">$3</span>.
935936
If this does not indicate a bug, it can usually fixed with adding <span class="code">@ignore($3)</span>
936937
in class <span class="code">$1</span>.`
937938
},
@@ -947,9 +948,8 @@ qx.Class.define("qxl.packagebrowser.PackageBrowser", {
947948
description:
948949
`The file <span class="code">$2</span> is not valid according to
949950
<a target="_blank" href="https://github.com/qooxdoo/qooxdoo-compiler/tree/master/source/resource/qx/tool/schema">
950-
the current JSON Schema</a>. The validation error is: $3.`
951+
the current JSON Schema</a>. The validation error is: <span class="code">$3</span>.`
951952
}
952-
//
953953
];
954954
const explainMessages =
955955
compilation_log
@@ -1054,7 +1054,7 @@ qx.Class.define("qxl.packagebrowser.PackageBrowser", {
10541054
div.innerText = release.body;
10551055
let description = div.innerHTML;
10561056
return `
1057-
<h2>${release.name} ${titleSuffixes.length ? ("(" + titleSuffixes.join(", ") + ")") : ""}</h2>
1057+
<h2><a href="${release.html_url}" target="_blank">${release.name} ${titleSuffixes.length ? ("(" + titleSuffixes.join(", ") + ")") : ""}</a></h2>
10581058
<p style="font-weight: bold">${tagHtml}Published at ${datePublished.toLocaleDateString()}, ${datePublished.toLocaleTimeString()} (${daysSincePublished} days ago)</p>
10591059
<p>${description}</p>
10601060
`;

0 commit comments

Comments
 (0)