Socket
Socket
Sign inDemoInstall

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.16.0 to 0.17.0

113

built/cli.js

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

const node_watch_1 = require("node-watch");
const fetch = require('node-fetch');
function downloadProjectAsync(id) {

@@ -353,2 +354,6 @@ return __awaiter(this, void 0, void 0, function* () {

if (!fs.existsSync("pxt.json")) {
if (!template) {
error("missing template");
process.exit(1);
}
const target = loader_1.descriptors.find(t => t.id === template);

@@ -375,2 +380,8 @@ if (!target) {

}
else {
if (template) {
error("directory is not empty, cannot apply template");
process.exit(1);
}
}
if (!fs.existsSync("tsconfig.json")) {

@@ -398,2 +409,98 @@ msg("saving tsconfig.json");

}
function makeCodeExtensions() {
return __awaiter(this, void 0, void 0, function* () {
let data = [];
try {
const r = yield fetch("https://raw.githubusercontent.com/microsoft/jacdac/main/services/makecode-extensions.json");
data = (yield r.json());
}
catch (e) {
}
return data;
});
}
function join(...parts) {
return parts.filter(p => !!p).join('/');
}
// parse https://github.com/[company]/[project](/filepath)(#tag)
function parseRepoId(repo) {
if (!repo)
return undefined;
// clean out whitespaces
repo = repo.trim();
// trim trailing /
repo = repo.replace(/\/$/, '');
// convert github pages into github repo
const mgh = /^https:\/\/([^./#]+)\.github\.io\/([^/#]+)\/?$/i.exec(repo);
if (mgh)
repo = `github:${mgh[1]}/${mgh[2]}`;
repo = repo.replace(/^github:/i, "");
repo = repo.replace(/^https:\/\/github\.com\//i, "");
repo = repo.replace(/\.git\b/i, "");
const m = /^([^#\/:]+)\/([^#\/:]+)(\/([^#]+))?(#([^\/:]*))?$/.exec(repo);
if (!m)
return undefined;
const owner = m[1];
const project = m[2];
let fileName = m[4];
const tag = m[6];
const treeM = fileName && /^tree\/([^\/]+\/)/.exec(fileName);
if (treeM) {
// https://github.com/pelikhan/mono-demo/tree/master/demo2
fileName = fileName.slice(treeM[0].length);
// branch info?
}
return {
owner,
project,
slug: join(owner, project),
fullName: join(owner, project, fileName),
tag,
fileName
};
}
function fetchExtension(slug) {
return __awaiter(this, void 0, void 0, function* () {
const url = `https://pxt.azureedge.net/api/gh/${slug}`;
const req = yield fetch(url);
if (req.status !== 200) {
error(`resolution of ${slug} failed (${req.status})`);
process.exit(1);
}
const script = (yield req.json());
return script;
});
}
function addCommand(repo, opts) {
return __awaiter(this, void 0, void 0, function* () {
applyGlobalOptions(opts);
opts.pxtModules = true;
msg(`adding ${repo}`);
const prj = yield resolveProject(opts);
repo = repo.toLowerCase();
if (/^jacdac-/.test(repo)) {
const exts = yield makeCodeExtensions();
const ext = exts.find(ext => ext.client.name === repo);
if (ext) {
info(`found jacdac ${ext.client.repo}`);
repo = ext.client.repo;
}
}
const rid = parseRepoId(repo);
if (!rid) {
error("unkown repository format, try https://github.com/.../...");
process.exit(1);
}
const d = yield fetchExtension(rid.slug);
const pxtJson = yield prj.readPxtConfig();
const name = join(rid.project, rid.fileName).replace(/^pxt-/, '').replace("/", "-");
pxtJson.dependencies[name] = `github:${rid.fullName}#${d.version ? `v${d.version}` : d.defaultBranch}`;
fs.writeFileSync("pxt.json", JSON.stringify(pxtJson, null, 4), { encoding: "utf-8" });
// reload
{
const prj = yield resolveProject(opts);
yield prj.maybeWritePxtModulesAsync();
}
});
}
function isKV(v) {

@@ -482,3 +589,3 @@ return !!v && typeof v === "object" && !Array.isArray(v);

createCommand("init")
.addArgument(new commander_1.Argument("<template>", "project template name").choices(loader_1.descriptors.map(d => d.id)))
.addArgument(new commander_1.Argument("[template]", "project template name").choices(loader_1.descriptors.map(d => d.id)))
.description("initializes the project, optionally for a particular editor")

@@ -491,2 +598,6 @@ .option("--symlink-pxt-modules", "symlink files in pxt_modules/* for auto-completion")

.action(cleanCommand);
createCommand("add [repo]")
.description("add new dependencies")
.option("-c, --config-path <file>", "set configuration file path (default: \"mkc.json\")")
.action(addCommand);
yield commander_1.program.parseAsync(process.argv);

@@ -493,0 +604,0 @@ });

3

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

@@ -53,2 +53,3 @@ "keywords": [

"glob": "^7.2.0",
"node-fetch": "^2.0.0",
"node-watch": "^0.7.2"

@@ -55,0 +56,0 @@ },

@@ -87,2 +87,16 @@ # MKC - command line tool for MakeCode editors

### mkc add
Adds a new dependency to the project. Pass a GitHub repository URL to the ``add`` command.
```
mkc add https://github.com/microsoft/pxt-jacdac/button
```
For Jacdac extensions, simply write ``jacdac-servicename``
```
mkc add jacdac-button
```
### mkc bump

@@ -89,0 +103,0 @@

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