Skip to content

Commit de2cd28

Browse files
authored
Embedfix (microsoft#7194)
* added upgrade logging * adding comments * good old editor.main.css * updated test plan * updated docs * updated logging
1 parent e54dafb commit de2cd28

3 files changed

Lines changed: 49 additions & 5 deletions

File tree

common-docs/release-tests.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ This page list the set of test passes required for a new release.
66

77
* [Internet Explorer](/release-tests/ie)
88
* [Windows App](/release-tests/uwp)
9+
* Electron // TODO
910

1011
## Features #features
1112

1213
* [Tutorials](/release-tests/tutorials)
1314
* [Documentation](/release-tests/documentation)
14-
* [Sharing](/releases-tests/tutorials)
15+
* [Sharing](/release-tests/sharing)
1516
* [Extensions](/release-tests/extensions)

common-docs/release-tests/sharing.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Click the **X** icon
1818
* the dialog closes and no URL is generated
1919

20-
## Embed #embed
20+
## Embed Code #embed
2121

2222
* Open the Editor and drag a few blocks
2323
* Click on **Share**, then **Publish**
@@ -27,6 +27,26 @@
2727
3. Copy the text in the HTML section
2828
4. Click Run and verify that the blocks render
2929

30+
## Embed Editor #editor
31+
32+
* Open the Editor and drag a few blocks
33+
* Click on **Share**, then **Publish**
34+
* Click on **Embed**
35+
1. Copy the content of the **Editor** tab
36+
2. Open https://jsfiddle.net
37+
3. Copy the text in the HTML section
38+
4. Click Run and verify that the blocks render
39+
40+
## Embed Simulator #simulator
41+
42+
* Open the Editor and drag a few blocks
43+
* Click on **Share**, then **Publish**
44+
* Click on **Embed**
45+
1. Copy the content of the **Simulator** tab
46+
2. Open https://jsfiddle.net
47+
3. Copy the text in the HTML section
48+
4. Click Run and verify that the blocks render
49+
3050
## Additional Tests
3151

3252
* [Test Plan](/testplan)

pxtlib/package.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,24 +318,27 @@ namespace pxt {
318318
return regex.test(ts);
319319
}
320320

321-
private upgradePackagesAsync() {
321+
private upgradePackagesAsync(): Promise<pxt.Map<string>> {
322322
if (!this.config)
323323
this.loadConfig();
324324
return pxt.packagesConfigAsync()
325325
.then(packagesConfig => {
326326
let numfixes = 0
327+
let fixes: pxt.Map<string> = {};
327328
U.iterMap(this.config.dependencies, (pkg, ver) => {
328329
if (pxt.github.isGithubId(ver)) {
329330
const upgraded = pxt.github.upgradedPackageReference(packagesConfig, ver)
330331
if (upgraded && upgraded != ver) {
331332
pxt.log(`upgrading dep ${pkg}: ${ver} -> ${upgraded}`);
333+
fixes[ver] = upgraded;
332334
this.config.dependencies[pkg] = upgraded
333335
numfixes++
334336
}
335337
}
336338
})
337339
if (numfixes)
338340
this.saveConfig()
341+
return numfixes && fixes;
339342
})
340343
}
341344

@@ -567,12 +570,32 @@ namespace pxt {
567570
initPromise = initPromise.then(() => this.parseConfig(str))
568571
}
569572

570-
if (this.level == 0)
571-
initPromise = initPromise.then(() => this.upgradePackagesAsync())
573+
// if we are installing this script, we haven't yet downloaded the config
574+
// do upgrade later
575+
if (this.level == 0 && !isInstall) {
576+
initPromise = initPromise.then(() => this.upgradePackagesAsync().then(() => { }))
577+
}
572578

573579
if (isInstall)
574580
initPromise = initPromise.then(() => this.downloadAsync())
575581

582+
// we are installing the script, and we've download the original version and we haven't upgraded it yet
583+
// do upgrade and reload as needed
584+
if (this.level == 0 && isInstall) {
585+
initPromise = initPromise.then(() => this.upgradePackagesAsync())
586+
.then(fixes => {
587+
if (fixes) {
588+
// worst case scenario with double load
589+
Object.keys(fixes).forEach(key => pxt.tickEvent("package.doubleload", { "extension": key }))
590+
pxt.log(`upgraded, downloading again`);
591+
pxt.debug(fixes);
592+
return this.downloadAsync();
593+
}
594+
// nothing to do here
595+
else return Promise.resolve();
596+
})
597+
}
598+
576599
if (appTarget.simulator && appTarget.simulator.dynamicBoardDefinition) {
577600
if (this.level == 0)
578601
initPromise = initPromise.then(() => this.patchCorePackage());

0 commit comments

Comments
 (0)