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.11.0 to 0.12.0

75

built/cli.js

@@ -85,3 +85,3 @@ "use strict";

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

@@ -95,2 +95,3 @@ .option("-d, --download <URL>", "download project from share URL")

.option("-m, --pxt-modules", "write pxt_modules/*")
.option("--link-pxt-modules", "write pxt_modules/* adhering to 'links' field in mkc.json (for pxt cli build)")
.option("--always-built", "always generate files in built/ folder (and not built/hw-variant/)")

@@ -163,18 +164,8 @@ .option("--colors", "force color output")

const targetId = prj.service.runSync("pxt.appTarget.id");
let moreHw = [];
const outputs = [];
if (opts.hw) {
const hw = opts.hw.toLowerCase();
const selected = hwVariants.filter(cfg => {
return cfg.name.toLowerCase() == hw ||
hwid(cfg).toLowerCase() == hw ||
cfg.card.name.toLowerCase() == hw;
});
if (!selected.length) {
error(`No such HW id: ${opts.hw}`);
msg(`Available hw:`);
for (let cfg of hwVariants) {
msg(`${hwid(cfg)}, ${cfg.card.name} - ${cfg.card.description}`);
}
process.exit(1);
}
prj.hwVariant = hwid(selected[0]);
const hws = opts.hw.split(/[\s,;]+/);
selectHW(hws[0]);
moreHw = hws.slice(1);
}

@@ -186,2 +177,6 @@ if (opts.initMkc) {

prj.writePxtModules = !!opts.pxtModules;
if (opts.linkPxtModules) {
prj.writePxtModules = true;
prj.linkPxtModules = true;
}
if (!opts.javaScript || opts.hw)

@@ -193,6 +188,5 @@ opts.native = true;

prj.guessHwVariant();
info(`using hwVariant: ${prj.mainPkg.mkcConfig.hwVariant} (target ${targetId})`);
if (!opts.alwaysBuilt)
prj.outputPrefix = "built/" + prj.mainPkg.mkcConfig.hwVariant;
infoHW();
}
outputs.push(prj.outputPrefix);
const compileRes = yield buildOnePrj(opts, prj);

@@ -245,2 +239,23 @@ if (compileRes && opts.deploy) {

}
else if (success && moreHw.length) {
for (const hw of moreHw) {
selectHW(hw);
infoHW();
outputs.push(prj.outputPrefix);
yield buildOnePrj(opts, prj);
}
const uf2s = [];
for (const folder of outputs) {
try {
uf2s.push(fs.readFileSync(path.join(folder, "binary.uf2")));
}
catch (_a) { }
}
if (uf2s.length > 1) {
const total = Buffer.concat(uf2s);
const fn = "built/combined.uf2";
info(`combining ${uf2s.length} UF2 files into ${fn} (${Math.round(total.length / 1024)}kB)`);
fs.writeFileSync(fn, total);
}
}
if (success) {

@@ -257,2 +272,24 @@ msg("Build OK");

}
function selectHW(hw0) {
const hw = hw0.toLowerCase();
const selected = hwVariants.filter(cfg => {
return cfg.name.toLowerCase() == hw ||
hwid(cfg).toLowerCase() == hw ||
cfg.card.name.toLowerCase() == hw;
});
if (!selected.length) {
error(`No such HW id: ${hw0}`);
msg(`Available hw:`);
for (let cfg of hwVariants) {
msg(`${hwid(cfg)}, ${cfg.card.name} - ${cfg.card.description}`);
}
process.exit(1);
}
prj.hwVariant = hwid(selected[0]);
}
function infoHW() {
info(`using hwVariant: ${prj.mainPkg.mkcConfig.hwVariant} (target ${targetId})`);
if (!opts.alwaysBuilt)
prj.outputPrefix = "built/" + prj.mainPkg.mkcConfig.hwVariant;
}
});

@@ -259,0 +296,0 @@ }

import * as mkc from "./mkc";
export declare function findParentDirWith(base: string, filename: string): string;
export declare function findProjectDir(): string;
export declare function relativePath(currdir: string, target: string): string;
export declare function fileExists(name: string): boolean;
export declare function readPrjFileAsync(dir: string, filename: string): Promise<string>;

@@ -5,0 +7,0 @@ export declare function readProjectAsync(dir: string): Promise<pxt.Map<string>>;

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.savePxtModulesAsync = exports.saveBuiltFilesAsync = exports.writeFilesAsync = exports.mkHomeCache = exports.readProjectAsync = exports.readPrjFileAsync = exports.findProjectDir = exports.findParentDirWith = void 0;
exports.savePxtModulesAsync = exports.saveBuiltFilesAsync = exports.writeFilesAsync = exports.mkHomeCache = exports.readProjectAsync = exports.readPrjFileAsync = exports.fileExists = exports.relativePath = exports.findProjectDir = exports.findParentDirWith = void 0;
const fs = require("fs");

@@ -42,2 +42,10 @@ const path = require("path");

}
function relativePath(currdir, target) {
return path.relative(currdir, target);
}
exports.relativePath = relativePath;
function fileExists(name) {
return fs.existsSync(name);
}
exports.fileExists = fileExists;
function readPrjFileAsync(dir, filename) {

@@ -44,0 +52,0 @@ return readAsync(resolveFilename(dir, filename), "utf8");

@@ -48,2 +48,3 @@ /// <reference path="../external/pxtpackage.d.ts" />

writePxtModules: boolean;
linkPxtModules: boolean;
outputPrefix: string;

@@ -50,0 +51,0 @@ mkcConfig: MkcJson;

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

this.writePxtModules = true;
this.linkPxtModules = false;
this.outputPrefix = "built";

@@ -70,2 +71,39 @@ if (!this.cache)

savePxtModulesAsync(filesmap) {
var _a;
if (this.linkPxtModules) {
filesmap = JSON.parse(JSON.stringify(filesmap));
const pxtmod = "pxt_modules/";
const filesByPkg = {};
const filenames = Object.keys(filesmap);
for (const s of filenames) {
if (s.startsWith(pxtmod)) {
const id = s.slice(pxtmod.length).replace(/\/.*/, "");
if (!filesByPkg[id])
filesByPkg[id] = [];
filesByPkg[id].push(s);
}
}
for (const id of Object.keys(filesByPkg)) {
let lnk = (_a = this.mkcConfig.links) === null || _a === void 0 ? void 0 : _a[id];
let rel = "";
if (lnk)
rel = exports.files.relativePath(this.directory + "/pxt_modules/foobar", lnk);
else if (exports.files.fileExists(`../../libs/${id}/pxt.json`)) {
lnk = `../../libs/${id}`;
rel = `../../${lnk}`;
}
if (lnk) {
for (const fn of filesByPkg[id])
delete filesmap[fn];
exports.log(`link ${id} -> ${lnk}`);
const pxtJson = JSON.stringify({
additionalFilePath: rel
}, null, 4);
filesmap["pxt_modules/" + id + "/pxt.json"] = pxtJson;
if (/---/.test(id)) {
filesmap["pxt_modules/" + id.replace(/---.*/, "") + "/pxt.json"] = pxtJson;
}
}
}
}
return exports.files.savePxtModulesAsync(this.directory, filesmap);

@@ -72,0 +110,0 @@ }

{
"name": "makecode",
"version": "0.11.0",
"version": "0.12.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

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