pxt-core 7.5.39 → 7.5.40

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/cli.js CHANGED
@@ -5053,6 +5053,7 @@ function checkFileSize(files) {
5053
5053
  return maxSize;
5054
5054
  }
5055
5055
  function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
5056
+ var _a;
5056
5057
  if (!nodeutil.existsDirSync("docs"))
5057
5058
  return Promise.resolve();
5058
5059
  const docsRoot = nodeutil.targetDir;
@@ -5230,6 +5231,13 @@ function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
5230
5231
  // test targetconfig
5231
5232
  if (nodeutil.fileExistsSync("targetconfig.json")) {
5232
5233
  const targetConfig = nodeutil.readJson("targetconfig.json");
5234
+ if ((_a = targetConfig === null || targetConfig === void 0 ? void 0 : targetConfig.packages) === null || _a === void 0 ? void 0 : _a.approvedRepoLib) {
5235
+ for (const repoSlug of Object.keys(targetConfig.packages.approvedRepoLib)) {
5236
+ if (repoSlug !== repoSlug.toLocaleLowerCase()) {
5237
+ U.userError(`targetconfig.json: repo slugs in approvedRepoLib must be lowercased.\n\tError: ${repoSlug}`);
5238
+ }
5239
+ }
5240
+ }
5233
5241
  if (targetConfig && targetConfig.galleries) {
5234
5242
  Object.keys(targetConfig.galleries).forEach(k => {
5235
5243
  pxt.log(`gallery ${k}`);
@@ -5741,7 +5749,7 @@ function testGithubPackagesAsync(parsed) {
5741
5749
  .then(() => nodeutil.mkdirP(pkgsroot))
5742
5750
  .then(() => pxt.github.searchAsync("", packages))
5743
5751
  .then(ghrepos => ghrepos.filter(ghrepo => ghrepo.status == pxt.github.GitRepoStatus.Approved)
5744
- .map(ghrepo => ghrepo.fullName).concat(packages.approvedRepos || []))
5752
+ .map(ghrepo => ghrepo.fullName).concat(Object.keys(packages.approvedRepoLib || {})))
5745
5753
  .then(fullnames => {
5746
5754
  // remove dups
5747
5755
  fullnames = U.unique(fullnames, f => f.toLowerCase());
package/built/pxt.js CHANGED
@@ -108170,13 +108170,13 @@ var pxt;
108170
108170
  return false;
108171
108171
  }
108172
108172
  function isRepoApproved(repo, config) {
108173
+ var _a;
108173
108174
  if (isOrgApproved(repo, config))
108174
108175
  return true;
108175
108176
  if (!repo || !config)
108176
108177
  return false;
108177
108178
  if (repo.fullName
108178
- && config.approvedRepos
108179
- && config.approvedRepos.some(fn => fn.toLowerCase() == repo.fullName.toLowerCase()))
108179
+ && ((_a = config.approvedRepoLib) === null || _a === void 0 ? void 0 : _a[repo.fullName.toLowerCase()]))
108180
108180
  return true;
108181
108181
  return false;
108182
108182
  }
@@ -108309,52 +108309,59 @@ var pxt;
108309
108309
  return parts.filter(p => !!p).join('/');
108310
108310
  }
108311
108311
  github.join = join;
108312
- function upgradeRule(cfg, id) {
108313
- if (!cfg || !cfg.upgrades)
108312
+ function upgradeRules(cfg, id) {
108313
+ if (!cfg)
108314
108314
  return null;
108315
108315
  const parsed = parseRepoId(id);
108316
108316
  if (!parsed)
108317
108317
  return null;
108318
- // lookup base repo for upgrade rules
108318
+ const repoData = cfg.approvedRepoLib;
108319
+ // lookup base repo for upgrade rules
108319
108320
  // (since nested repoes share the same version number)
108320
- return pxt.U.lookup(cfg.upgrades, parsed.slug.toLowerCase());
108321
+ return cfg.approvedRepoLib && pxt.U.lookup(cfg.approvedRepoLib, parsed.slug.toLowerCase()).upgrades;
108321
108322
  }
108322
108323
  function upgradedDisablesVariants(cfg, id) {
108323
- const upgr = upgradeRule(cfg, id);
108324
- const m = /^dv:(.*)/.exec(upgr);
108325
- if (m) {
108326
- const disabled = m[1].split(/,/);
108327
- if (disabled.some(d => !/^\w+$/.test(d)))
108328
- return null;
108329
- return disabled;
108324
+ const rules = upgradeRules(cfg, id) || [];
108325
+ if (!rules)
108326
+ return null;
108327
+ for (const upgr of rules) {
108328
+ const m = /^dv:(.*)/.exec(upgr);
108329
+ if (m) {
108330
+ const disabled = m[1].split(/,/);
108331
+ if (disabled.some(d => !/^\w+$/.test(d)))
108332
+ return null;
108333
+ return disabled;
108334
+ }
108330
108335
  }
108331
108336
  return null;
108332
108337
  }
108333
108338
  function upgradedPackageReference(cfg, id) {
108334
- const upgr = upgradeRule(cfg, id);
108335
- if (!upgr)
108339
+ const rules = upgradeRules(cfg, id);
108340
+ if (!rules)
108336
108341
  return null;
108337
- const m = /^min:(.*)/.exec(upgr);
108338
- const minV = m && pxt.semver.tryParse(m[1]);
108339
- if (minV) {
108340
- const parsed = parseRepoId(id);
108341
- const currV = pxt.semver.tryParse(parsed.tag);
108342
- if (currV && pxt.semver.cmp(currV, minV) < 0) {
108343
- parsed.tag = m[1];
108344
- pxt.debug(`upgrading ${id} to ${m[1]}`);
108345
- return stringifyRepo(parsed);
108342
+ for (const upgr of rules) {
108343
+ const m = /^min:(.*)/.exec(upgr);
108344
+ const minV = m && pxt.semver.tryParse(m[1]);
108345
+ if (minV) {
108346
+ const parsed = parseRepoId(id);
108347
+ const currV = pxt.semver.tryParse(parsed.tag);
108348
+ if (currV && pxt.semver.cmp(currV, minV) < 0) {
108349
+ parsed.tag = m[1];
108350
+ pxt.debug(`upgrading ${id} to ${m[1]}`);
108351
+ return stringifyRepo(parsed);
108352
+ }
108353
+ else {
108354
+ if (!currV)
108355
+ pxt.log(`not upgrading ${id} - cannot parse version`);
108356
+ return null;
108357
+ }
108346
108358
  }
108347
108359
  else {
108348
- if (!currV)
108349
- pxt.log(`not upgrading ${id} - cannot parse version`);
108350
- return null;
108360
+ // check if the rule looks valid at all
108361
+ if (!upgradedDisablesVariants(cfg, id))
108362
+ pxt.log(`invalid upgrade rule: ${id} -> ${upgr}`);
108351
108363
  }
108352
108364
  }
108353
- else {
108354
- // check if the rule looks valid at all
108355
- if (!upgradedDisablesVariants(cfg, id))
108356
- pxt.log(`invalid upgrade rule: ${id} -> ${upgr}`);
108357
- }
108358
108365
  return id;
108359
108366
  }
108360
108367
  github.upgradedPackageReference = upgradedPackageReference;
@@ -162202,6 +162209,7 @@ function checkFileSize(files) {
162202
162209
  return maxSize;
162203
162210
  }
162204
162211
  function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
162212
+ var _a;
162205
162213
  if (!nodeutil.existsDirSync("docs"))
162206
162214
  return Promise.resolve();
162207
162215
  const docsRoot = nodeutil.targetDir;
@@ -162379,6 +162387,13 @@ function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
162379
162387
  // test targetconfig
162380
162388
  if (nodeutil.fileExistsSync("targetconfig.json")) {
162381
162389
  const targetConfig = nodeutil.readJson("targetconfig.json");
162390
+ if ((_a = targetConfig === null || targetConfig === void 0 ? void 0 : targetConfig.packages) === null || _a === void 0 ? void 0 : _a.approvedRepoLib) {
162391
+ for (const repoSlug of Object.keys(targetConfig.packages.approvedRepoLib)) {
162392
+ if (repoSlug !== repoSlug.toLocaleLowerCase()) {
162393
+ U.userError(`targetconfig.json: repo slugs in approvedRepoLib must be lowercased.\n\tError: ${repoSlug}`);
162394
+ }
162395
+ }
162396
+ }
162382
162397
  if (targetConfig && targetConfig.galleries) {
162383
162398
  Object.keys(targetConfig.galleries).forEach(k => {
162384
162399
  pxt.log(`gallery ${k}`);
@@ -162890,7 +162905,7 @@ function testGithubPackagesAsync(parsed) {
162890
162905
  .then(() => nodeutil.mkdirP(pkgsroot))
162891
162906
  .then(() => pxt.github.searchAsync("", packages))
162892
162907
  .then(ghrepos => ghrepos.filter(ghrepo => ghrepo.status == pxt.github.GitRepoStatus.Approved)
162893
- .map(ghrepo => ghrepo.fullName).concat(packages.approvedRepos || []))
162908
+ .map(ghrepo => ghrepo.fullName).concat(Object.keys(packages.approvedRepoLib || {})))
162894
162909
  .then(fullnames => {
162895
162910
  // remove dups
162896
162911
  fullnames = U.unique(fullnames, f => f.toLowerCase());
package/built/pxtlib.js CHANGED
@@ -10484,13 +10484,13 @@ var pxt;
10484
10484
  return false;
10485
10485
  }
10486
10486
  function isRepoApproved(repo, config) {
10487
+ var _a;
10487
10488
  if (isOrgApproved(repo, config))
10488
10489
  return true;
10489
10490
  if (!repo || !config)
10490
10491
  return false;
10491
10492
  if (repo.fullName
10492
- && config.approvedRepos
10493
- && config.approvedRepos.some(fn => fn.toLowerCase() == repo.fullName.toLowerCase()))
10493
+ && ((_a = config.approvedRepoLib) === null || _a === void 0 ? void 0 : _a[repo.fullName.toLowerCase()]))
10494
10494
  return true;
10495
10495
  return false;
10496
10496
  }
@@ -10623,52 +10623,59 @@ var pxt;
10623
10623
  return parts.filter(p => !!p).join('/');
10624
10624
  }
10625
10625
  github.join = join;
10626
- function upgradeRule(cfg, id) {
10627
- if (!cfg || !cfg.upgrades)
10626
+ function upgradeRules(cfg, id) {
10627
+ if (!cfg)
10628
10628
  return null;
10629
10629
  const parsed = parseRepoId(id);
10630
10630
  if (!parsed)
10631
10631
  return null;
10632
- // lookup base repo for upgrade rules
10632
+ const repoData = cfg.approvedRepoLib;
10633
+ // lookup base repo for upgrade rules
10633
10634
  // (since nested repoes share the same version number)
10634
- return pxt.U.lookup(cfg.upgrades, parsed.slug.toLowerCase());
10635
+ return cfg.approvedRepoLib && pxt.U.lookup(cfg.approvedRepoLib, parsed.slug.toLowerCase()).upgrades;
10635
10636
  }
10636
10637
  function upgradedDisablesVariants(cfg, id) {
10637
- const upgr = upgradeRule(cfg, id);
10638
- const m = /^dv:(.*)/.exec(upgr);
10639
- if (m) {
10640
- const disabled = m[1].split(/,/);
10641
- if (disabled.some(d => !/^\w+$/.test(d)))
10642
- return null;
10643
- return disabled;
10638
+ const rules = upgradeRules(cfg, id) || [];
10639
+ if (!rules)
10640
+ return null;
10641
+ for (const upgr of rules) {
10642
+ const m = /^dv:(.*)/.exec(upgr);
10643
+ if (m) {
10644
+ const disabled = m[1].split(/,/);
10645
+ if (disabled.some(d => !/^\w+$/.test(d)))
10646
+ return null;
10647
+ return disabled;
10648
+ }
10644
10649
  }
10645
10650
  return null;
10646
10651
  }
10647
10652
  function upgradedPackageReference(cfg, id) {
10648
- const upgr = upgradeRule(cfg, id);
10649
- if (!upgr)
10653
+ const rules = upgradeRules(cfg, id);
10654
+ if (!rules)
10650
10655
  return null;
10651
- const m = /^min:(.*)/.exec(upgr);
10652
- const minV = m && pxt.semver.tryParse(m[1]);
10653
- if (minV) {
10654
- const parsed = parseRepoId(id);
10655
- const currV = pxt.semver.tryParse(parsed.tag);
10656
- if (currV && pxt.semver.cmp(currV, minV) < 0) {
10657
- parsed.tag = m[1];
10658
- pxt.debug(`upgrading ${id} to ${m[1]}`);
10659
- return stringifyRepo(parsed);
10656
+ for (const upgr of rules) {
10657
+ const m = /^min:(.*)/.exec(upgr);
10658
+ const minV = m && pxt.semver.tryParse(m[1]);
10659
+ if (minV) {
10660
+ const parsed = parseRepoId(id);
10661
+ const currV = pxt.semver.tryParse(parsed.tag);
10662
+ if (currV && pxt.semver.cmp(currV, minV) < 0) {
10663
+ parsed.tag = m[1];
10664
+ pxt.debug(`upgrading ${id} to ${m[1]}`);
10665
+ return stringifyRepo(parsed);
10666
+ }
10667
+ else {
10668
+ if (!currV)
10669
+ pxt.log(`not upgrading ${id} - cannot parse version`);
10670
+ return null;
10671
+ }
10660
10672
  }
10661
10673
  else {
10662
- if (!currV)
10663
- pxt.log(`not upgrading ${id} - cannot parse version`);
10664
- return null;
10674
+ // check if the rule looks valid at all
10675
+ if (!upgradedDisablesVariants(cfg, id))
10676
+ pxt.log(`invalid upgrade rule: ${id} -> ${upgr}`);
10665
10677
  }
10666
10678
  }
10667
- else {
10668
- // check if the rule looks valid at all
10669
- if (!upgradedDisablesVariants(cfg, id))
10670
- pxt.log(`invalid upgrade rule: ${id} -> ${upgr}`);
10671
- }
10672
10679
  return id;
10673
10680
  }
10674
10681
  github.upgradedPackageReference = upgradedPackageReference;