pxt-core 13.2.2 → 13.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/built/pxtlib.d.ts CHANGED
@@ -1543,7 +1543,7 @@ declare namespace pxt.github {
1543
1543
  function createReleaseAsync(repopath: string, tag: string, commitid: string): Promise<void>;
1544
1544
  function createPRFromBranchAsync(repopath: string, baseBranch: string, headBranch: string, title: string, msg?: string): Promise<string>;
1545
1545
  function mergeAsync(repopath: string, base: string, head: string, message?: string): Promise<string>;
1546
- function getRefAsync(repopath: string, branch: string): Promise<any>;
1546
+ function getRefAsync(repopath: string, branch: string): Promise<string | undefined>;
1547
1547
  function getNewBranchNameAsync(repopath: string, pref?: string): Promise<string>;
1548
1548
  function createNewBranchAsync(repopath: string, branchName: string, commitid: string): Promise<string>;
1549
1549
  function forkRepoAsync(repopath: string, commitid: string, pref?: string): Promise<string>;
package/built/pxtlib.js CHANGED
@@ -10890,8 +10890,29 @@ var pxt;
10890
10890
  }
10891
10891
  async loadConfigAsync(repopath, tag) {
10892
10892
  if (!tag) {
10893
- pxt.debug(`dep: default to master branch`);
10894
- tag = "master";
10893
+ pxt.debug(`dep: no tag specified, try master and main`);
10894
+ let res;
10895
+ let error;
10896
+ try {
10897
+ res = await this.loadConfigAsync(repopath, "master");
10898
+ }
10899
+ catch (e) {
10900
+ error = e;
10901
+ pxt.log(`Error loading default master config for ${repopath}: ${e.message}`);
10902
+ }
10903
+ if (res)
10904
+ return res;
10905
+ try {
10906
+ res = await this.loadConfigAsync(repopath, "main");
10907
+ }
10908
+ catch (e) {
10909
+ error = e;
10910
+ pxt.log(`Error loading default main config for ${repopath}: ${e.message}`);
10911
+ }
10912
+ if (res)
10913
+ return res;
10914
+ else
10915
+ throw error;
10895
10916
  }
10896
10917
  // cache lookup
10897
10918
  const key = `${repopath}/${tag}`;
@@ -10925,8 +10946,29 @@ var pxt;
10925
10946
  }
10926
10947
  async loadPackageAsync(repopath, tag, fallbackPackageFiles) {
10927
10948
  if (!tag) {
10928
- pxt.debug(`load pkg: default to master branch`);
10929
- tag = "master";
10949
+ pxt.debug(`load pkg: no tag specified, try master and main`);
10950
+ let res;
10951
+ let error;
10952
+ try {
10953
+ res = await this.loadPackageAsync(repopath, "master", fallbackPackageFiles);
10954
+ }
10955
+ catch (e) {
10956
+ error = e;
10957
+ pxt.log(`Error loading default master package for ${repopath}: ${e.message}`);
10958
+ }
10959
+ if (res)
10960
+ return res;
10961
+ try {
10962
+ res = await this.loadPackageAsync(repopath, "main", fallbackPackageFiles);
10963
+ }
10964
+ catch (e) {
10965
+ error = e;
10966
+ pxt.log(`Error loading default main package for ${repopath}: ${e.message}`);
10967
+ }
10968
+ if (res)
10969
+ return res;
10970
+ else
10971
+ throw error;
10930
10972
  }
10931
10973
  // try using github proxy first
10932
10974
  if (hasProxy()) {
@@ -11212,16 +11254,27 @@ var pxt;
11212
11254
  });
11213
11255
  }
11214
11256
  github.mergeAsync = mergeAsync;
11215
- function getRefAsync(repopath, branch) {
11216
- branch = branch || "master";
11217
- return ghGetJsonAsync("https://api.github.com/repos/" + repopath + "/git/refs/heads/" + branch)
11218
- .then(resolveRefAsync)
11219
- .catch(err => {
11220
- if (err.statusCode == 404)
11257
+ async function getRefAsync(repopath, branch) {
11258
+ if (!branch) {
11259
+ // try master and main
11260
+ let res = await getRefAsync(repopath, "master");
11261
+ if (!res)
11262
+ res = await getRefAsync(repopath, "main");
11263
+ return res;
11264
+ }
11265
+ try {
11266
+ const ref = await ghGetJsonAsync("https://api.github.com/repos/" + repopath + "/git/refs/heads/" + branch);
11267
+ return resolveRefAsync(ref);
11268
+ }
11269
+ catch (e) {
11270
+ pxt.debug(`Error fetching ref for ${repopath} branch ${branch}: ${e.message}`);
11271
+ if (e.statusCode === 404) {
11221
11272
  return undefined;
11222
- else
11223
- Promise.reject(err);
11224
- });
11273
+ }
11274
+ else {
11275
+ throw e;
11276
+ }
11277
+ }
11225
11278
  }
11226
11279
  github.getRefAsync = getRefAsync;
11227
11280
  function generateNextRefName(res, pref) {