pxt-core 12.2.23 → 12.2.25

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
@@ -390,12 +390,30 @@ async function ciAsync(parsed) {
390
390
  pxt.log(`upload docs: ${uploadDocs}`);
391
391
  lintJSONInDirectory(path.resolve("."));
392
392
  lintJSONInDirectory(path.resolve("docs"));
393
- function npmPublishAsync() {
393
+ let pkg = readJson("package.json");
394
+ async function npmPublishAsync() {
394
395
  if (!npmPublish)
395
396
  return Promise.resolve();
397
+ let latest;
398
+ try {
399
+ const version = await nodeutil.npmLatestVersionAsync(pkg["name"]);
400
+ latest = pxt.semver.parse(version);
401
+ }
402
+ catch (e) {
403
+ // no latest tag
404
+ }
405
+ let distTag;
406
+ if (latest) {
407
+ const current = pxt.semver.parse(pkg["version"]);
408
+ if (pxt.semver.cmp(current, latest) < 0) {
409
+ distTag = `stable${current.major}.${current.minor}`;
410
+ }
411
+ }
412
+ if (distTag) {
413
+ return nodeutil.runNpmAsync("publish", "--tag", distTag);
414
+ }
396
415
  return nodeutil.runNpmAsync("publish");
397
416
  }
398
- let pkg = readJson("package.json");
399
417
  if (pkg["name"] == "pxt-core") {
400
418
  pxt.log("pxt-core build");
401
419
  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
@@ -163580,12 +163580,30 @@ async function ciAsync(parsed) {
163580
163580
  pxt.log(`upload docs: ${uploadDocs}`);
163581
163581
  lintJSONInDirectory(path.resolve("."));
163582
163582
  lintJSONInDirectory(path.resolve("docs"));
163583
- function npmPublishAsync() {
163583
+ let pkg = readJson("package.json");
163584
+ async function npmPublishAsync() {
163584
163585
  if (!npmPublish)
163585
163586
  return Promise.resolve();
163587
+ let latest;
163588
+ try {
163589
+ const version = await nodeutil.npmLatestVersionAsync(pkg["name"]);
163590
+ latest = pxt.semver.parse(version);
163591
+ }
163592
+ catch (e) {
163593
+ // no latest tag
163594
+ }
163595
+ let distTag;
163596
+ if (latest) {
163597
+ const current = pxt.semver.parse(pkg["version"]);
163598
+ if (pxt.semver.cmp(current, latest) < 0) {
163599
+ distTag = `stable${current.major}.${current.minor}`;
163600
+ }
163601
+ }
163602
+ if (distTag) {
163603
+ return nodeutil.runNpmAsync("publish", "--tag", distTag);
163604
+ }
163586
163605
  return nodeutil.runNpmAsync("publish");
163587
163606
  }
163588
- let pkg = readJson("package.json");
163589
163607
  if (pkg["name"] == "pxt-core") {
163590
163608
  pxt.log("pxt-core build");
163591
163609
  const isTaggedCommit = await checkIfTaggedCommitAsync();