Comparing version 0.22.0 to 0.23.0
@@ -19,2 +19,2 @@ /// <reference types="node" /> | ||
export declare function monoRepoConfigs(folder: string, includingSelf?: boolean): string[]; | ||
export declare function bumpAsync(prj: mkc.Project): Promise<void>; | ||
export declare function bumpAsync(prj: mkc.Project, versionFile: string, stage: boolean): Promise<void>; |
@@ -108,7 +108,11 @@ "use strict"; | ||
exports.monoRepoConfigs = monoRepoConfigs; | ||
function bumpAsync(prj) { | ||
function bumpAsync(prj, versionFile, stage) { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield needsGitCleanAsync(); | ||
yield runGitAsync("pull"); | ||
if (stage) | ||
mkc.log(`operation staged, skipping git commit/push`); | ||
if (!stage) { | ||
yield needsGitCleanAsync(); | ||
yield runGitAsync("pull"); | ||
} | ||
const cfg = prj.mainPkg.config; | ||
@@ -119,2 +123,14 @@ const m = /^(\d+\.\d+)\.(\d+)(.*)/.exec(cfg.version); | ||
cfg.version = newV; | ||
if (versionFile) { | ||
mkc.log(`writing version ${newV} in ${versionFile}`); | ||
const versionSrc = ` | ||
// Auto-generated file: do not edit. | ||
namespace ${cfg.name.replace(/^pxt-/, '').split(/-/g).map((p, i) => i == 0 ? p : (p[0].toUpperCase() + p.slice(1))).join("")} { | ||
/** | ||
* Version of the library | ||
*/ | ||
export const VERSION = "${newV}" | ||
}`; | ||
fs.writeFileSync(versionFile, versionSrc, { encoding: "utf-8" }); | ||
} | ||
const configs = monoRepoConfigs(prj.directory, false); | ||
@@ -131,22 +147,24 @@ if (configs.length > 0) { | ||
yield files.writeFilesAsync(prj.directory, { "pxt.json": mkc.stringifyConfig(cfg) }, true); | ||
yield runGitAsync("commit", "-a", "-m", newV); | ||
yield runGitAsync("tag", "v" + newV); | ||
yield runGitAsync("push"); | ||
yield runGitAsync("push", "--tags"); | ||
const urlinfo = yield spawnWithPipeAsync({ | ||
cmd: "git", | ||
args: ["remote", "get-url", "origin"], | ||
pipe: true | ||
}).then(v => v, err => { | ||
mkc.error(err); | ||
return null; | ||
}); | ||
const url = (_a = urlinfo === null || urlinfo === void 0 ? void 0 : urlinfo.toString("utf8")) === null || _a === void 0 ? void 0 : _a.trim(); | ||
if (url) { | ||
const slug = url.replace(/.*github\.com\//i, ""); | ||
if (slug != url) { | ||
mkc.log(`Github slug ${slug}; refreshing makecode.com cache`); | ||
const res = yield (0, downloader_1.httpGetJsonAsync)("https://makecode.com/api/gh/" + slug + "/refs?nocache=1"); | ||
const sha = (_b = res === null || res === void 0 ? void 0 : res.refs) === null || _b === void 0 ? void 0 : _b["refs/tags/v" + newV]; | ||
mkc.log(`refreshed ${newV} -> ${sha}`); | ||
if (!stage) { | ||
yield runGitAsync("commit", "-a", "-m", newV); | ||
yield runGitAsync("tag", "v" + newV); | ||
yield runGitAsync("push"); | ||
yield runGitAsync("push", "--tags"); | ||
const urlinfo = yield spawnWithPipeAsync({ | ||
cmd: "git", | ||
args: ["remote", "get-url", "origin"], | ||
pipe: true | ||
}).then(v => v, err => { | ||
mkc.error(err); | ||
return null; | ||
}); | ||
const url = (_a = urlinfo === null || urlinfo === void 0 ? void 0 : urlinfo.toString("utf8")) === null || _a === void 0 ? void 0 : _a.trim(); | ||
if (url) { | ||
const slug = url.replace(/.*github\.com\//i, ""); | ||
if (slug != url) { | ||
mkc.log(`Github slug ${slug}; refreshing makecode.com cache`); | ||
const res = yield (0, downloader_1.httpGetJsonAsync)("https://makecode.com/api/gh/" + slug + "/refs?nocache=1"); | ||
const sha = (_b = res === null || res === void 0 ? void 0 : res.refs) === null || _b === void 0 ? void 0 : _b["refs/tags/v" + newV]; | ||
mkc.log(`refreshed ${newV} -> ${sha}`); | ||
} | ||
} | ||
@@ -153,0 +171,0 @@ } |
@@ -377,3 +377,3 @@ "use strict"; | ||
const prj = yield resolveProject(opts); | ||
yield bump.bumpAsync(prj); | ||
yield bump.bumpAsync(prj, opts === null || opts === void 0 ? void 0 : opts.versionFile, opts === null || opts === void 0 ? void 0 : opts.stage); | ||
}); | ||
@@ -665,2 +665,4 @@ } | ||
.description("interactive version incrementer for a project or mono-repo") | ||
.option("--version-file <file>", "write generated version number into the file") | ||
.option("--stage", "skip git commit and push operations") | ||
.action(bumpCommand); | ||
@@ -667,0 +669,0 @@ createCommand("init") |
{ | ||
"name": "makecode", | ||
"version": "0.22.0", | ||
"version": "0.23.0", | ||
"description": "MakeCode (PXT) - web-cached build tool", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -135,2 +135,14 @@ # MKC - command line tool for MakeCode editors | ||
Adding ``--version-file`` will make `mkc` write a TypeScript file with the version number. | ||
``` | ||
mkc bump --version-file version.ts | ||
``` | ||
Add ``--stage`` to test the bump without pushing to git. | ||
``` | ||
mkc --stage | ||
``` | ||
### mkc download | ||
@@ -137,0 +149,0 @@ |
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
199727
3013
231
32