Comparing version 0.0.1 to 0.0.3
@@ -40,2 +40,3 @@ "use strict"; | ||
.option("-i, --init-mkc", "initialize mkc.json") | ||
.option("--always-built", "always generate files in built/ folder (and not built/hw-variant/)") | ||
.parse(process.argv); | ||
@@ -80,2 +81,4 @@ const opts = commander_1.program; | ||
console.log(`using hwVariant: ${prj.mainPkg.mkcConfig.hwVariant}`); | ||
if (!opts.alwaysBuilt) | ||
prj.outputPrefix = "built/" + prj.mainPkg.mkcConfig.hwVariant; | ||
} | ||
@@ -85,4 +88,20 @@ const simpleOpts = { | ||
}; | ||
yield prj.buildAsync(simpleOpts); | ||
console.log("all done"); | ||
const res = yield prj.buildAsync(simpleOpts); | ||
let output = ""; | ||
for (let diagnostic of res.diagnostics) { | ||
const category = diagnostic.category == 1 ? "error" : diagnostic.category == 2 ? "warning" : "message"; | ||
if (diagnostic.fileName) | ||
output += `${diagnostic.fileName}(${diagnostic.line + 1},${diagnostic.column + 1}): `; | ||
output += `${category} TS${diagnostic.code}: ${diagnostic.messageText}\n`; | ||
} | ||
if (output) | ||
console.log(output.replace(/\n$/, "")); | ||
if (res.success) { | ||
console.log("Build OK"); | ||
process.exit(0); | ||
} | ||
else { | ||
console.log("Build failed"); | ||
process.exit(1); | ||
} | ||
function hwid(cfg) { | ||
@@ -89,0 +108,0 @@ return cfg.name.replace(/hw---/, ""); |
@@ -6,3 +6,3 @@ import * as mkc from "./mkc"; | ||
export declare function mkHomeCache(dir?: string): mkc.Cache; | ||
export declare function saveBuiltFilesAsync(dir: string, res: mkc.service.CompileResult): Promise<void>; | ||
export declare function saveBuiltFilesAsync(dir: string, res: mkc.service.CompileResult, folder?: string): Promise<void>; | ||
export declare function savePxtModulesAsync(dir: string, ws: mkc.Workspace): Promise<void>; |
@@ -78,5 +78,8 @@ "use strict"; | ||
exports.mkHomeCache = mkHomeCache; | ||
function mkdirp(dirname) { | ||
if (!fs.existsSync(dirname)) | ||
function mkdirp(dirname, lev = 5) { | ||
if (!fs.existsSync(dirname)) { | ||
if (lev > 0) | ||
mkdirp(path.resolve(dirname, ".."), lev - 1); | ||
fs.mkdirSync(dirname); | ||
} | ||
} | ||
@@ -95,5 +98,5 @@ function writeFilesAsync(built, outfiles, log = false) { | ||
} | ||
function saveBuiltFilesAsync(dir, res) { | ||
function saveBuiltFilesAsync(dir, res, folder = "built") { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield writeFilesAsync(path.join(dir, "built"), res.outfiles || {}, true); | ||
yield writeFilesAsync(path.join(dir, folder), res.outfiles || {}, true); | ||
}); | ||
@@ -100,0 +103,0 @@ } |
@@ -67,3 +67,6 @@ "use strict"; | ||
pending.push(pkgid); | ||
if (ver == "*" || /^file:/.test(ver)) { | ||
if (mkcJson.links && mkcJson.links[pkgid]) { | ||
text = (yield mkc.files.readProjectAsync(mkcJson.links[pkgid])).files; | ||
} | ||
else if (ver == "*" || /^file:/.test(ver)) { | ||
text = ed.targetJson.bundledpkgs[pkgid]; | ||
@@ -70,0 +73,0 @@ if (!text) |
@@ -11,2 +11,3 @@ /// <reference path="../external/pxtpackage.d.ts" /> | ||
hwVariant?: string; | ||
links?: pxt.Map<string>; | ||
} | ||
@@ -47,2 +48,3 @@ export interface Cache { | ||
writePxtModules: boolean; | ||
outputPrefix: string; | ||
constructor(directory: string, cache?: Cache); | ||
@@ -49,0 +51,0 @@ get hwVariant(): string; |
@@ -25,2 +25,3 @@ "use strict"; | ||
this.writePxtModules = true; | ||
this.outputPrefix = "built"; | ||
if (!this.cache) | ||
@@ -41,3 +42,3 @@ this.cache = exports.files.mkHomeCache(); | ||
saveBuiltFilesAsync(res) { | ||
return exports.files.saveBuiltFilesAsync(this.directory, res); | ||
return exports.files.saveBuiltFilesAsync(this.directory, res, this.outputPrefix); | ||
} | ||
@@ -44,0 +45,0 @@ savePxtModulesAsync(ws) { |
{ | ||
"name": "makecode", | ||
"version": "0.0.1", | ||
"version": "0.0.3", | ||
"description": "MakeCode (PXT) - web-cached build tool", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
# MakeCode build tool | ||
# MKC - command line tool for MakeCode editors | ||
@@ -18,5 +18,36 @@ This package includes a tool that can compile MakeCode (PXT) projects by | ||
You can also pass `--hw f4`, `--hw d5` etc. Try `--hw help` to get a list. | ||
Use `makecode -j` to build JavaScript (it defaults to native). | ||
## License | ||
The tool is configured with optional `mkc.json` file. Example: | ||
MIT | ||
```json | ||
{ | ||
"targetWebsite": "https://arcade.makecode.com/beta", | ||
"hwVariant": "samd51", | ||
"links": { | ||
"jacdac-services": "../../pxt-jacdac-services" | ||
} | ||
} | ||
``` | ||
All fields are optional. | ||
* **targetWebsite** says where to take the compiler from; if you omit it, it will be guessed based on packages used by `pxt.json`; | ||
you can point this to a live or beta version of the editor, as well as to a specific version (including SHA-indexed uploads | ||
generated during PXT target builds) | ||
* **hwVariant** specifies default hardware variant (currently only used in Arcade); try `--hw help` command line option to list variants | ||
* **links** overrides specific packages; these can be github packages or built-in packages | ||
## Contributing | ||
This project welcomes contributions and suggestions. Most contributions require you to agree to a | ||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us | ||
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. | ||
When you submit a pull request, a CLA bot will automatically determine whether you need to provide | ||
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions | ||
provided by the bot. You will only need to do this once across all repos using our CLA. | ||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). | ||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or | ||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87520
26
1330
53