Skip to content

Commit ca62eb1

Browse files
authored
Merge branch 'master' into UpdateVirtualSelectBox
2 parents 7b60275 + 4b8da56 commit ca62eb1

File tree

14 files changed

+261
-270
lines changed

14 files changed

+261
-270
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
run: npm install @qooxdoo/compiler --no-save
2020

2121
- name: Build
22-
run: npx qx deploy --out=./html --clean --source-maps
22+
run: npx qx deploy --out=./html --clean --source-maps --verbose
2323

2424
- name: Deploy
2525
uses: peaceiris/actions-gh-pages@v3

.gitignore

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# .gitignore template for skeleton-based apps
2-
/*-output/
3-
/db.json
4-
/resource-db.json
5-
/qooxdoo/
6-
/qx_packages/*
7-
/node_modules/
8-
compiled
2+
/qx_packages
3+
/node_modules
4+
/compiled
5+
/html
96
/.vscode
7+
/.idea

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Clone this repo and compile it:
1212
```bash
1313
git clone https://github.com/qooxdoo/qxl.demobrowser
1414
cd qxl.demobrowser
15-
npm install @qooxdoo/compiler
15+
npm install --no-save --no-package-lock @qooxdoo/compiler
1616
npx qx serve
1717
```
1818
Then open [http://localhost:8080](http://localhost:8080)

compile.js

Lines changed: 114 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,89 @@
1-
qx.Class.define("qxl.demobrowser.compile.LibraryApi", {
2-
extend: qx.tool.cli.api.LibraryApi,
1+
const fs = require("fs");
2+
let path;
3+
let async;
4+
5+
qx.Class.define("qxl.demobrowser.compile.CompilerApi", {
6+
extend: qx.tool.cli.api.CompilerApi,
37

48
members: {
59
async load() {
6-
let command = this.getCompilerApi().getCommand();
7-
if (command instanceof qx.tool.cli.commands.Compile) {
8-
command.addListener("writtenApplication", (e) => this.__appCompiling(e.getData()));
9-
}
10+
this.addListener("changeCommand", function () {
11+
let command = this.getCommand();
12+
if (command instanceof qx.tool.cli.commands.Compile) {
13+
command.addListener("writtenApplication", async (evt) => {
14+
await this.__build(evt.getData());
15+
});
16+
}
17+
if (command instanceof qx.tool.cli.commands.Deploy) {
18+
command.addListener("afterDeploy", async (evt) => {
19+
await this.__deploy(evt.getData());
20+
});
21+
}
22+
}, this);
23+
return this.base(arguments);
24+
},
25+
26+
/**
27+
let data = {
28+
targetDir: target.getOutputDir(),
29+
deployDir: deployDir,
30+
argv: argv,
31+
application: app
32+
};
33+
*/
34+
__deploy(data) {
35+
console.info(">>> Installing dependencies ...");
36+
const path = this.require("upath");
37+
console.info(">>> deploy files ...");
38+
return Promise.all([
39+
qx.tool.utils.files.Utils.sync(path.join(data.targetDir, "demobrowser", "demo"), path.join(data.deployDir, "demobrowser", "demo")),
40+
qx.tool.utils.files.Utils.sync(path.join(data.targetDir, "demobrowser", "script"), path.join(data.deployDir, "demobrowser", "script"))
41+
]);
1042
},
11-
12-
__appCompiling(application) {
43+
44+
/**
45+
* Fired when writing of single application is complete; data is an object containing:
46+
* maker {qx.tool.compiler.makers.Maker}
47+
* target {qx.tool.compiler.targets.Target}
48+
* appMeta {qx.tool.compiler.targets.meta.ApplicationMeta}
49+
*/
50+
__build(data) {
51+
let application = data.appMeta.getApplication();
1352
let className = application.getClassName();
1453
if (className !== "qxl.demobrowser.Application") {
1554
return;
1655
}
1756

18-
let command = this.getCompilerApi().getCommand();
19-
let maker = command.getMakersForApp(application.getName())[0];
20-
let analyser = maker.getAnalyser();
57+
console.info(">>> Installing dependencies ...");
58+
const path = this.require("upath");
59+
const async = this.require("async");
60+
// needed by DataGenerator
61+
this.require('walker');
62+
console.info(">>> Generating Demobrowser data... this might take a while");
63+
let command = this.getCommand();
64+
let analyser = data.maker.getAnalyser();
2165
const templateDir = command.getTemplateDir();
22-
const outputDir = maker.getTarget().getOutputDir();
66+
const outputDir = data.maker.getTarget().getOutputDir();
2367
const sourceDir = analyser.findLibrary("qxl.demobrowser").getRootDir();
2468
let targetClass = command.resolveTargetClass(command._getConfig().targetType);
69+
let app = "demobrowser";
2570

26-
return new qx.Promise((fullfiled) => {
27-
let app = application.getName();
28-
29-
const path = this.require("upath");
30-
const async = this.require("async");
31-
32-
// needed by DataGenerator
33-
this.require('walker');
34-
this.require('mkdirp');
35-
71+
return new qx.Promise(fullfilled => {
3672
const DataGenerator = require(path.join(sourceDir, "tool/lib/DataGenerator"));
3773
// global vars
3874
const config = {
39-
demoPath: path.join(sourceDir,"source/demo/"),
75+
demoPath: path.join(sourceDir, "source/demo/"),
4076
demoDataJsonFile: path.join(outputDir, app, "script/demodata.json"),
41-
classPath: path.join(sourceDir,"source/class"),
42-
jsSourcePath: path.join(sourceDir,"source/class/qxl/demobrowser/demo"),
77+
classPath: path.join(sourceDir, "source/class"),
78+
jsSourcePath: path.join(sourceDir, "source/class/qxl/demobrowser/demo"),
4379
demoConfigJsonFile: path.join(outputDir, app, "config.demo.json"),
4480
verbose: command.argv.verbose
4581
};
4682
let appInfos = [];
4783
let dataGenerator = new DataGenerator(config);
4884
async.series([
4985
(cb) => {
50-
console.info("\nDEMO BUILD STARTED");
86+
console.info("- Start building...");
5187
cb();
5288
},
5389
// catches all the demos from config.demoPath
@@ -57,7 +93,7 @@ qx.Class.define("qxl.demobrowser.compile.LibraryApi", {
5793
// copy all javascript files to config.scriptDestinationPath
5894
dataGenerator.copyJsFiles.bind(dataGenerator),
5995
(cb) => {
60-
console.info("\nget apps");
96+
console.info("- Get applications");
6197
let environment = {
6298
"qx.allowUrlVariants": true,
6399
"qx.allowUrlSettings": true,
@@ -70,10 +106,10 @@ qx.Class.define("qxl.demobrowser.compile.LibraryApi", {
70106
if (file.level === 2) {
71107
let demoCategory = dataGenerator.getDemoCategoryFromFile(file.path);
72108
let className = 'qxl.demobrowser.demo.' + demoCategory.category + '.' + demoCategory.name;
73-
let outDir = path.join(demoCategory.category, demoCategory.name);
109+
let outDir = path.join(demoCategory.category, demoCategory.name);
74110
let library = analyser.getLibraryFromClassname(className);
75111
if (!library) {
76-
console.info("no class found for " + file.path);
112+
console.error("! no class found for " + file.path);
77113
return;
78114
}
79115
appInfos.push({
@@ -82,6 +118,8 @@ qx.Class.define("qxl.demobrowser.compile.LibraryApi", {
82118
"qx.theme.Modern",
83119
"qx.theme.Simple",
84120
"qx.theme.Classic",
121+
"qx.theme.TangibleLight",
122+
"qx.theme.TangibleDark",
85123
"qx.log.appender.Native",
86124
"qx.log.appender.Console"
87125
]).set({
@@ -95,58 +133,86 @@ qx.Class.define("qxl.demobrowser.compile.LibraryApi", {
95133
"qx.theme.Indigo",
96134
"qx.theme.Modern",
97135
"qx.theme.Simple",
98-
"qx.theme.Classic"
136+
"qx.theme.Classic",
137+
"qx.theme.TangibleLight",
138+
"qx.theme.TangibleDark"
99139
],
100140
templatePath: templateDir
101141
}),
102-
className: className
142+
className: className,
143+
fileName: analyser.getClassFilename(className)
103144
});
104145
}
105146
});
106147
cb();
107148
},
108149
(cb) => {
109-
console.info("DEMO BUILD START COMPILE");
150+
console.info("- Compiling ...");
110151
let target = new targetClass(outputDir);
111152
target.set({
112153
generateIndexHtml: false,
113154
analyser: analyser
114155
});
115156
async.eachSeries(appInfos,
116157
(appInfo, cb) => {
117-
// Calculate dependencies and write it out
118-
appInfo.app.setAnalyser(analyser);
119-
appInfo.app.calcDependencies();
120-
if (command.argv.verbose) {
121-
console.info("Writing class " + appInfo.app.getClassName() + " into " + appInfo.app.getOutputPath());
122-
}
123-
target.generateApplication(appInfo.app, appInfo.app.getEnvironment())
124-
.then(() => cb())
125-
.catch((err) => {
126-
console.error(err.message);
127-
cb(err);
128-
});
158+
let dest = path.join(target.getOutputDir(), appInfo.app.getOutputPath(), "index.js");
159+
let src = appInfo.fileName;
160+
this.__fileDateDiffers(src, dest).then((needsWork) => {
161+
if (!needsWork) {
162+
cb();
163+
return;
164+
}
165+
// Calculate dependencies and write it out
166+
appInfo.app.setAnalyser(analyser);
167+
appInfo.app.calcDependencies();
168+
if (command.argv.verbose) {
169+
console.info("- Writing class " + appInfo.app.getClassName() + " into " + appInfo.app.getOutputPath());
170+
}
171+
target.generateApplication(appInfo.app, appInfo.app.getEnvironment())
172+
.then(() => cb())
173+
.catch((err) => {
174+
console.error(err.message);
175+
cb(err);
176+
});
177+
});
129178
},
130179
cb)
131180
},
132181
(cb) => {
133-
qx.tool.utils.files.Utils.sync(path.join(sourceDir,"source/demo/"), path.join(outputDir, app, "demo"))
182+
qx.tool.utils.files.Utils.sync(path.join(sourceDir, "source/demo/"), path.join(outputDir, app, "demo"))
134183
.then(() => cb())
135184
.catch((err) => {
136185
console.error(err.message);
137186
cb(err);
138187
});
139188
},
140189
(cb) => {
141-
console.info("\nDEMO BUILD FINISHED");
190+
console.info("- Demo build finished.");
142191
cb();
143192
}
144-
], fullfiled);
193+
], fullfilled);
145194
});
195+
},
196+
197+
async __fileDateDiffers(src, dest) {
198+
let srcStat = await qx.tool.utils.files.Utils.safeStat(src);
199+
if (!srcStat) {
200+
// nothing to coy in this case
201+
return false;
202+
}
203+
if (!fs.existsSync(dest)) {
204+
return true;
205+
}
206+
let destStat = await qx.tool.utils.files.Utils.safeStat(dest);
207+
if (!destStat || (srcStat.mtime.getTime() > destStat.mtime.getTime())) {
208+
return true;
209+
}
210+
return false;
146211
}
212+
147213
}
148214
});
149215

150216
module.exports = {
151-
LibraryApi: qxl.demobrowser.compile.LibraryApi
217+
CompilerApi: qxl.demobrowser.compile.CompilerApi
152218
};

compile.json

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,55 @@
11
{
2-
"$schema": "https://qooxdoo.org/schema/compile-1-0-0.json",
3-
"environment": {
4-
"qx.allowUrlVariants": true,
5-
"qx.allowUrlSettings": true,
6-
"qx.contrib": false,
7-
"qx.icontheme": ["Tango", "Oxygen"]
8-
},
9-
"applications": [{
10-
"class": "qxl.demobrowser.Application",
11-
"theme": "qxl.demobrowser.Theme",
12-
"name": "demobrowser",
13-
"title": "DemoBrowser",
14-
"bootPath": "source/boot",
15-
"include": [
16-
"qxl.demobrowser.*",
17-
"qx.theme.Indigo",
18-
"qx.theme.Modern",
19-
"qx.theme.Simple",
20-
"qx.theme.Classic"
21-
]
22-
}],
23-
/** Targets */
24-
"targets": [{
25-
"type": "source",
26-
"outputPath": "compiled/source",
27-
"bundle": {
28-
"include": "qx.*"
29-
},
30-
"babelOptions": {
31-
"targets": {
32-
"edge": "18",
33-
"chrome": "73",
34-
"firefox": "66"
35-
}
36-
}
37-
},
38-
{
39-
"type": "build",
40-
"outputPath": "compiled/build"
41-
}
42-
],
43-
"defaultTarget": "source",
44-
"locales": [
45-
"en"
46-
],
47-
"serve": {
48-
"listenPort": 8080
49-
}
50-
}
2+
"$schema": "https://qooxdoo.org/schema/compile-1-0-0.json",
3+
"environment": {
4+
"qx.allowUrlVariants": true,
5+
"qx.allowUrlSettings": true,
6+
"qx.contrib": false,
7+
"qx.icontheme": [
8+
"Tango",
9+
"Oxygen"
10+
]
11+
},
12+
"applications": [{
13+
"class": "qxl.demobrowser.Application",
14+
"theme": "qx.theme.Indigo",
15+
"name": "demobrowser",
16+
"title": "DemoBrowser",
17+
"bootPath": "source/boot",
18+
"include": [
19+
"qxl.demobrowser.*",
20+
"qx.theme.Indigo",
21+
"qx.theme.Modern",
22+
"qx.theme.Simple",
23+
"qx.theme.Classic",
24+
"qx.theme.TangibleLight",
25+
"qx.theme.TangibleDark"
26+
]
27+
}
28+
],
29+
"targets": [{
30+
"type": "source",
31+
"outputPath": "compiled/source",
32+
"bundle": {
33+
"include": "qx.*"
34+
},
35+
"babelOptions": {
36+
"targets": {
37+
"edge": "18",
38+
"chrome": "73",
39+
"firefox": "66"
40+
}
41+
}
42+
}, {
43+
"type": "build",
44+
"outputPath": "compiled/build",
45+
"deployPath": "html"
46+
}
47+
],
48+
"defaultTarget": "source",
49+
"locales": [
50+
"en"
51+
],
52+
"serve": {
53+
"listenPort": 8080
54+
}
55+
}

0 commit comments

Comments
 (0)