pxt-core 12.0.16 → 12.0.18

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
@@ -349,13 +349,9 @@ async function ciAsync(parsed) {
349
349
  tag = tagOverride;
350
350
  pxt.log(`overriding tag to ${tag}`);
351
351
  }
352
- const atok = process.env.NPM_ACCESS_TOKEN;
353
- const npmPublish = (intentToPublish || /^v\d+\.\d+\.\d+$/.exec(tag)) && atok;
352
+ const npmPublish = /^v\d+\.\d+\.\d+$/.exec(tag) && process.env.NPM_PUBLISH;
354
353
  if (npmPublish) {
355
- let npmrc = path.join(process.env.HOME, ".npmrc");
356
- pxt.log(`setting up ${npmrc} for publish`);
357
- let cfg = "//registry.npmjs.org/:_authToken=" + atok + "\n";
358
- fs.writeFileSync(npmrc, cfg);
354
+ pxt.log(`npm publish is true`);
359
355
  }
360
356
  else if (intentToPublish) {
361
357
  pxt.log("not publishing, no tag or access token");
@@ -381,12 +377,30 @@ async function ciAsync(parsed) {
381
377
  pxt.log(`upload docs: ${uploadDocs}`);
382
378
  lintJSONInDirectory(path.resolve("."));
383
379
  lintJSONInDirectory(path.resolve("docs"));
384
- function npmPublishAsync() {
380
+ let pkg = readJson("package.json");
381
+ async function npmPublishAsync() {
385
382
  if (!npmPublish)
386
383
  return Promise.resolve();
384
+ let latest;
385
+ try {
386
+ const version = await nodeutil.npmLatestVersionAsync(pkg["name"]);
387
+ latest = pxt.semver.parse(version);
388
+ }
389
+ catch (e) {
390
+ // no latest tag
391
+ }
392
+ let distTag;
393
+ if (latest) {
394
+ const current = pxt.semver.parse(pkg["version"]);
395
+ if (pxt.semver.cmp(current, latest) < 0) {
396
+ distTag = `stable${current.major}.${current.minor}`;
397
+ }
398
+ }
399
+ if (distTag) {
400
+ return nodeutil.runNpmAsync("publish", "--tag", distTag);
401
+ }
387
402
  return nodeutil.runNpmAsync("publish");
388
403
  }
389
- let pkg = readJson("package.json");
390
404
  if (pkg["name"] == "pxt-core") {
391
405
  pxt.log("pxt-core build");
392
406
  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
@@ -97927,7 +97927,7 @@ var pxt;
97927
97927
  auth.DEFAULT_USER_PREFERENCES = () => ({
97928
97928
  language: pxt.appTarget.appTheme.defaultLocale,
97929
97929
  highContrast: false,
97930
- accessibleBlocks: false,
97930
+ accessibleBlocks: undefined,
97931
97931
  colorThemeIds: {},
97932
97932
  reader: "",
97933
97933
  skillmap: { mapProgress: {}, completedTags: {} },
@@ -162573,13 +162573,9 @@ async function ciAsync(parsed) {
162573
162573
  tag = tagOverride;
162574
162574
  pxt.log(`overriding tag to ${tag}`);
162575
162575
  }
162576
- const atok = process.env.NPM_ACCESS_TOKEN;
162577
- const npmPublish = (intentToPublish || /^v\d+\.\d+\.\d+$/.exec(tag)) && atok;
162576
+ const npmPublish = /^v\d+\.\d+\.\d+$/.exec(tag) && process.env.NPM_PUBLISH;
162578
162577
  if (npmPublish) {
162579
- let npmrc = path.join(process.env.HOME, ".npmrc");
162580
- pxt.log(`setting up ${npmrc} for publish`);
162581
- let cfg = "//registry.npmjs.org/:_authToken=" + atok + "\n";
162582
- fs.writeFileSync(npmrc, cfg);
162578
+ pxt.log(`npm publish is true`);
162583
162579
  }
162584
162580
  else if (intentToPublish) {
162585
162581
  pxt.log("not publishing, no tag or access token");
@@ -162605,12 +162601,30 @@ async function ciAsync(parsed) {
162605
162601
  pxt.log(`upload docs: ${uploadDocs}`);
162606
162602
  lintJSONInDirectory(path.resolve("."));
162607
162603
  lintJSONInDirectory(path.resolve("docs"));
162608
- function npmPublishAsync() {
162604
+ let pkg = readJson("package.json");
162605
+ async function npmPublishAsync() {
162609
162606
  if (!npmPublish)
162610
162607
  return Promise.resolve();
162608
+ let latest;
162609
+ try {
162610
+ const version = await nodeutil.npmLatestVersionAsync(pkg["name"]);
162611
+ latest = pxt.semver.parse(version);
162612
+ }
162613
+ catch (e) {
162614
+ // no latest tag
162615
+ }
162616
+ let distTag;
162617
+ if (latest) {
162618
+ const current = pxt.semver.parse(pkg["version"]);
162619
+ if (pxt.semver.cmp(current, latest) < 0) {
162620
+ distTag = `stable${current.major}.${current.minor}`;
162621
+ }
162622
+ }
162623
+ if (distTag) {
162624
+ return nodeutil.runNpmAsync("publish", "--tag", distTag);
162625
+ }
162611
162626
  return nodeutil.runNpmAsync("publish");
162612
162627
  }
162613
- let pkg = readJson("package.json");
162614
162628
  if (pkg["name"] == "pxt-core") {
162615
162629
  pxt.log("pxt-core build");
162616
162630
  const isTaggedCommit = await checkIfTaggedCommitAsync();
package/built/pxtlib.js CHANGED
@@ -206,7 +206,7 @@ var pxt;
206
206
  auth.DEFAULT_USER_PREFERENCES = () => ({
207
207
  language: pxt.appTarget.appTheme.defaultLocale,
208
208
  highContrast: false,
209
- accessibleBlocks: false,
209
+ accessibleBlocks: undefined,
210
210
  colorThemeIds: {},
211
211
  reader: "",
212
212
  skillmap: { mapProgress: {}, completedTags: {} },