Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

makecode

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

makecode - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

built/deploy.d.ts

66

built/cli.js

@@ -14,2 +14,3 @@ "use strict";

const path = require("path");
const util = require("util");
const mkc = require("./mkc");

@@ -22,2 +23,3 @@ const files = require("./files");

const glob_1 = require("glob");
const deploy_1 = require("./deploy");
function downloadProjectAsync(id) {

@@ -52,7 +54,7 @@ return __awaiter(this, void 0, void 0, function* () {

console.log(output.replace(/\n$/, ""));
return res.success;
return res.success ? res : null;
}
catch (e) {
error("Exception: " + e.stack);
return false;
return null;
}

@@ -75,2 +77,3 @@ });

.option("-n, --native", "compile native (default)")
.option("-d, --deploy", "copy resulting binary to UF2 or HEX drive")
.option("-h, --hw <id>", "set hardware for which to compile (implies -n)")

@@ -97,2 +100,10 @@ .option("-j, --java-script", "compile to JavaScript")

chalk.level = 1;
if (opts.deploy && opts.monoRepo) {
error("--deploy and --mono-repo cannot be used together");
process.exit(1);
}
if (opts.deploy && opts.javaScript) {
error("--deploy and --java-script cannot be used together");
process.exit(1);
}
mkc.setLogging({

@@ -119,3 +130,9 @@ log: info,

info(`Using config: ${opts.configPath}`);
prj.mkcConfig = JSON.parse(fs.readFileSync(opts.configPath, "utf8"));
try {
prj.mkcConfig = JSON.parse(fs.readFileSync(opts.configPath, "utf8"));
}
catch (e) {
error(`Can't read config file: '${opts.configPath}'; ` + e.message);
process.exit(1);
}
const lnk = prj.mkcConfig.links;

@@ -172,3 +189,30 @@ if (lnk) {

}
let success = yield buildOnePrj(opts, prj);
const compileRes = yield buildOnePrj(opts, prj);
if (compileRes && opts.deploy) {
const firmwareName = ["binary.uf2", "binary.hex", "binary.elf"].filter(f => !!compileRes.outfiles[f])[0];
if (!firmwareName) { // something went wrong here
error(`firmware missing from built files (${Object.keys(compileRes.outfiles).join(', ')})`);
}
else {
const compileInfo = prj.service.runSync("pxt.appTarget.compile");
const drives = yield deploy_1.getDeployDrives(compileInfo);
if (drives.length == 0) {
msg("cannot find any drives to deploy to");
}
else {
const firmware = compileRes.outfiles[firmwareName];
const encoding = firmwareName == "binary.hex" ? "utf8" : "base64";
msg(`copying ${firmwareName} to ` + drives.join(", "));
const writeFileAsync = util.promisify(fs.writeFile);
const writeHexFile = (drivename) => {
return writeFileAsync(path.join(drivename, firmwareName), firmware, encoding)
.then(() => info(" wrote to " + drivename))
.catch(() => error(` failed writing to ${drivename}`));
};
for (const p of drives.map(writeHexFile))
yield p;
}
}
}
let success = !!compileRes;
if (success && opts.monoRepo) {

@@ -204,3 +248,15 @@ const dirs = glob_1.glob.sync("**/pxt.json");

}
mainCli();
function mainWrapper() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield mainCli();
}
catch (e) {
error("Exception: " + e.stack);
error("Build failed");
process.exit(1);
}
});
}
mainWrapper();
//# sourceMappingURL=cli.js.map

@@ -32,3 +32,4 @@ /// <reference types="node" />

versionNumber?: number;
updateCheckedAt?: number;
}
export declare function downloadAsync(cache: mkc.Cache, webAppUrl: string, useCached?: boolean): Promise<mkc.DownloadedEditor>;

@@ -164,6 +164,22 @@ "use strict";

const info = infoBuf ? JSON.parse(infoBuf.toString("utf8")) : {};
if (useCached && info.manifest)
return loadFromCacheAsync();
if (!(yield hasNewManifestAsync()))
return loadFromCacheAsync();
if (useCached && info.manifest) {
let needsUpdate = false;
if (!info.updateCheckedAt || Date.now() - info.updateCheckedAt > 24 * 3600 * 1000) {
info.updateCheckedAt = Date.now();
yield saveInfoAsync(); // save last check time *before* checking - in case user hits ctrl-c we don't want another build to hang again
try {
log("Checking for updates (only happens once daily)...");
needsUpdate = yield hasNewManifestAsync();
}
catch (e) {
log(`Error checking for updates; will try again tomorrow (use -u flag to force); ${e.message}`);
}
}
if (!needsUpdate)
return loadFromCacheAsync();
}
else {
if (!(yield hasNewManifestAsync()))
return loadFromCacheAsync();
}
log("Download new webapp");

@@ -180,2 +196,3 @@ const cfg = yield parseWebConfigAsync(webAppUrl);

info.versionNumber = (info.versionNumber || 0) + 1;
info.updateCheckedAt = Date.now();
for (let fn of ["pxtworker.js", "target.json"]) {

@@ -206,5 +223,8 @@ yield saveFileAsync(fn);

return loadFromCacheAsync();
function saveInfoAsync() {
return cache.setAsync(webAppUrl + "-info", Buffer.from(JSON.stringify(info), "utf8"));
}
function loadFromCacheAsync() {
return __awaiter(this, void 0, void 0, function* () {
yield cache.setAsync(webAppUrl + "-info", Buffer.from(JSON.stringify(info), "utf8"));
yield saveInfoAsync();
const res = {

@@ -238,7 +258,11 @@ cache,

});
if (resp.statusCode == 304)
if (resp.statusCode == 304) {
info.updateCheckedAt = Date.now();
return false;
}
info.manifestEtag = resp.headers["etag"];
if (resp.text == info.manifest)
if (resp.text == info.manifest) {
info.updateCheckedAt = Date.now();
return false;
}
info.manifest = resp.text;

@@ -245,0 +269,0 @@ return true;

2

package.json
{
"name": "makecode",
"version": "0.9.0",
"version": "0.10.0",
"description": "MakeCode (PXT) - web-cached build tool",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc