pxt-core 12.2.24 → 12.2.26

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.
@@ -1071,7 +1071,7 @@ ${opts.repo.name.replace(/^pxt-/, '')}=github:${opts.repo.fullName}#${opts.repo.
1071
1071
  }
1072
1072
  return r;
1073
1073
  }
1074
- html = html.replace(/<h(\d)[^>]+>\s*([~@])?\s*(.*?)<\/h\d>/g, (full, lvl, tp, body) => {
1074
+ html = html.replace(/<h(\d)[^>]*>\s*([~@])?\s*(.*?)<\/h\d>/g, (full, lvl, tp, body) => {
1075
1075
  let m = /^(\w+)\s+(.*)/.exec(body);
1076
1076
  let cmd = m ? m[1] : body;
1077
1077
  let args = m ? m[2] : "";
package/built/cli.js CHANGED
@@ -36,11 +36,12 @@ pxt.docs.requireDOMSanitizer = () => {
36
36
  const sanitizeHtml = require("sanitize-html");
37
37
  const defaults = sanitizeHtml.defaults || {};
38
38
  const baseAllowedAttrs = defaults.allowedAttributes || {};
39
+ const allowedTags = defaults.allowedTags || [];
39
40
  const mergeClassAttribute = (tag, ...otherAttributes) => {
40
41
  const existing = baseAllowedAttrs[tag] || [];
41
42
  return Array.from(new Set([...existing, "class", ...otherAttributes]));
42
43
  };
43
- const options = Object.assign(Object.assign({}, defaults), { allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title") }) });
44
+ const options = Object.assign(Object.assign({}, defaults), { allowedTags: [...allowedTags, "img"], allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title") }) });
44
45
  return (html) => sanitizeHtml(html, options);
45
46
  };
46
47
  let forceCloudBuild = process.env["KS_FORCE_CLOUD"] !== "no";
@@ -390,12 +391,30 @@ async function ciAsync(parsed) {
390
391
  pxt.log(`upload docs: ${uploadDocs}`);
391
392
  lintJSONInDirectory(path.resolve("."));
392
393
  lintJSONInDirectory(path.resolve("docs"));
393
- function npmPublishAsync() {
394
+ let pkg = readJson("package.json");
395
+ async function npmPublishAsync() {
394
396
  if (!npmPublish)
395
397
  return Promise.resolve();
398
+ let latest;
399
+ try {
400
+ const version = await nodeutil.npmLatestVersionAsync(pkg["name"]);
401
+ latest = pxt.semver.parse(version);
402
+ }
403
+ catch (e) {
404
+ // no latest tag
405
+ }
406
+ let distTag;
407
+ if (latest) {
408
+ const current = pxt.semver.parse(pkg["version"]);
409
+ if (pxt.semver.cmp(current, latest) < 0) {
410
+ distTag = `stable${current.major}.${current.minor}`;
411
+ }
412
+ }
413
+ if (distTag) {
414
+ return nodeutil.runNpmAsync("publish", "--tag", distTag);
415
+ }
396
416
  return nodeutil.runNpmAsync("publish");
397
417
  }
398
- let pkg = readJson("package.json");
399
418
  if (pkg["name"] == "pxt-core") {
400
419
  pxt.log("pxt-core build");
401
420
  const isTaggedCommit = await checkIfTaggedCommitAsync();
@@ -23,6 +23,7 @@ export declare function spawnAsync(opts: SpawnOptions): Promise<void>;
23
23
  export declare function spawnWithPipeAsync(opts: SpawnOptions): Promise<Buffer>;
24
24
  export declare function addCmd(name: string): string;
25
25
  export declare function runNpmAsync(...args: string[]): Promise<void>;
26
+ export declare function npmLatestVersionAsync(packageName: string): Promise<string>;
26
27
  export interface NpmRegistry {
27
28
  _id: string;
28
29
  _name: string;
package/built/nodeutil.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringify = exports.lazyRequire = exports.lazyDependencies = exports.getBundledPackagesDocs = exports.resolveMd = exports.lastResolveMdDirs = exports.fileExistsSync = exports.openUrl = exports.writeFileSync = exports.existsDirSync = exports.allFiles = exports.cp = exports.cpR = exports.mkdirP = exports.pathToPtr = exports.getPxtTarget = exports.readPkgConfig = exports.readText = exports.readJson = exports.sanitizePath = exports.timestamp = exports.isBranchProtectedAsync = exports.createPullRequestAsync = exports.gitPushAsync = exports.npmVersionBumpAsync = exports.getLocalTagPointingAtHeadAsync = exports.switchBranchAsync = exports.createBranchAsync = exports.getGitHubOwnerAndRepoAsync = exports.getGitHubUserAsync = exports.getGitHubTokenAsync = exports.getCurrentBranchNameAsync = exports.getDefaultBranchAsync = exports.needsGitCleanAsync = exports.currGitTagAsync = exports.gitInfoAsync = exports.runGitAsync = exports.runNpmAsyncWithCwd = exports.npmRegistryAsync = exports.runNpmAsync = exports.addCmd = exports.spawnWithPipeAsync = exports.spawnAsync = exports.readResAsync = exports.setTargetDir = exports.runCliFinalizersAsync = exports.addCliFinalizer = exports.cliFinalizers = exports.pxtCoreDir = exports.targetDir = void 0;
4
- exports.matchesAny = void 0;
3
+ exports.lazyRequire = exports.lazyDependencies = exports.getBundledPackagesDocs = exports.resolveMd = exports.lastResolveMdDirs = exports.fileExistsSync = exports.openUrl = exports.writeFileSync = exports.existsDirSync = exports.allFiles = exports.cp = exports.cpR = exports.mkdirP = exports.pathToPtr = exports.getPxtTarget = exports.readPkgConfig = exports.readText = exports.readJson = exports.sanitizePath = exports.timestamp = exports.isBranchProtectedAsync = exports.createPullRequestAsync = exports.gitPushAsync = exports.npmVersionBumpAsync = exports.getLocalTagPointingAtHeadAsync = exports.switchBranchAsync = exports.createBranchAsync = exports.getGitHubOwnerAndRepoAsync = exports.getGitHubUserAsync = exports.getGitHubTokenAsync = exports.getCurrentBranchNameAsync = exports.getDefaultBranchAsync = exports.needsGitCleanAsync = exports.currGitTagAsync = exports.gitInfoAsync = exports.runGitAsync = exports.runNpmAsyncWithCwd = exports.npmRegistryAsync = exports.npmLatestVersionAsync = exports.runNpmAsync = exports.addCmd = exports.spawnWithPipeAsync = exports.spawnAsync = exports.readResAsync = exports.setTargetDir = exports.runCliFinalizersAsync = exports.addCliFinalizer = exports.cliFinalizers = exports.pxtCoreDir = exports.targetDir = void 0;
4
+ exports.matchesAny = exports.stringify = void 0;
5
5
  const child_process = require("child_process");
6
6
  const fs = require("fs");
7
7
  const zlib = require("zlib");
@@ -101,6 +101,15 @@ function runNpmAsync(...args) {
101
101
  return runNpmAsyncWithCwd(".", ...args);
102
102
  }
103
103
  exports.runNpmAsync = runNpmAsync;
104
+ async function npmLatestVersionAsync(packageName) {
105
+ const output = await spawnWithPipeAsync({
106
+ cmd: addCmd("npm"),
107
+ args: ["view", packageName, "dist-tags.latest"],
108
+ cwd: ".",
109
+ });
110
+ return output.toString("utf8").trim();
111
+ }
112
+ exports.npmLatestVersionAsync = npmLatestVersionAsync;
104
113
  function npmRegistryAsync(pkg) {
105
114
  // TODO: use token if available
106
115
  return Util.httpGetJsonAsync(`https://registry.npmjs.org/${pkg}`);
package/built/pxt.js CHANGED
@@ -107281,7 +107281,7 @@ ${opts.repo.name.replace(/^pxt-/, '')}=github:${opts.repo.fullName}#${opts.repo.
107281
107281
  }
107282
107282
  return r;
107283
107283
  }
107284
- html = html.replace(/<h(\d)[^>]+>\s*([~@])?\s*(.*?)<\/h\d>/g, (full, lvl, tp, body) => {
107284
+ html = html.replace(/<h(\d)[^>]*>\s*([~@])?\s*(.*?)<\/h\d>/g, (full, lvl, tp, body) => {
107285
107285
  let m = /^(\w+)\s+(.*)/.exec(body);
107286
107286
  let cmd = m ? m[1] : body;
107287
107287
  let args = m ? m[2] : "";
@@ -163226,11 +163226,12 @@ pxt.docs.requireDOMSanitizer = () => {
163226
163226
  const sanitizeHtml = require("sanitize-html");
163227
163227
  const defaults = sanitizeHtml.defaults || {};
163228
163228
  const baseAllowedAttrs = defaults.allowedAttributes || {};
163229
+ const allowedTags = defaults.allowedTags || [];
163229
163230
  const mergeClassAttribute = (tag, ...otherAttributes) => {
163230
163231
  const existing = baseAllowedAttrs[tag] || [];
163231
163232
  return Array.from(new Set([...existing, "class", ...otherAttributes]));
163232
163233
  };
163233
- const options = Object.assign(Object.assign({}, defaults), { allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title") }) });
163234
+ const options = Object.assign(Object.assign({}, defaults), { allowedTags: [...allowedTags, "img"], allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title") }) });
163234
163235
  return (html) => sanitizeHtml(html, options);
163235
163236
  };
163236
163237
  let forceCloudBuild = process.env["KS_FORCE_CLOUD"] !== "no";
@@ -163580,12 +163581,30 @@ async function ciAsync(parsed) {
163580
163581
  pxt.log(`upload docs: ${uploadDocs}`);
163581
163582
  lintJSONInDirectory(path.resolve("."));
163582
163583
  lintJSONInDirectory(path.resolve("docs"));
163583
- function npmPublishAsync() {
163584
+ let pkg = readJson("package.json");
163585
+ async function npmPublishAsync() {
163584
163586
  if (!npmPublish)
163585
163587
  return Promise.resolve();
163588
+ let latest;
163589
+ try {
163590
+ const version = await nodeutil.npmLatestVersionAsync(pkg["name"]);
163591
+ latest = pxt.semver.parse(version);
163592
+ }
163593
+ catch (e) {
163594
+ // no latest tag
163595
+ }
163596
+ let distTag;
163597
+ if (latest) {
163598
+ const current = pxt.semver.parse(pkg["version"]);
163599
+ if (pxt.semver.cmp(current, latest) < 0) {
163600
+ distTag = `stable${current.major}.${current.minor}`;
163601
+ }
163602
+ }
163603
+ if (distTag) {
163604
+ return nodeutil.runNpmAsync("publish", "--tag", distTag);
163605
+ }
163586
163606
  return nodeutil.runNpmAsync("publish");
163587
163607
  }
163588
- let pkg = readJson("package.json");
163589
163608
  if (pkg["name"] == "pxt-core") {
163590
163609
  pxt.log("pxt-core build");
163591
163610
  const isTaggedCommit = await checkIfTaggedCommitAsync();
package/built/pxtlib.js CHANGED
@@ -9560,7 +9560,7 @@ ${opts.repo.name.replace(/^pxt-/, '')}=github:${opts.repo.fullName}#${opts.repo.
9560
9560
  }
9561
9561
  return r;
9562
9562
  }
9563
- html = html.replace(/<h(\d)[^>]+>\s*([~@])?\s*(.*?)<\/h\d>/g, (full, lvl, tp, body) => {
9563
+ html = html.replace(/<h(\d)[^>]*>\s*([~@])?\s*(.*?)<\/h\d>/g, (full, lvl, tp, body) => {
9564
9564
  let m = /^(\w+)\s+(.*)/.exec(body);
9565
9565
  let cmd = m ? m[1] : body;
9566
9566
  let args = m ? m[2] : "";