@zebralabs/context-cli 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/context.js +34 -7
package/package.json
CHANGED
package/src/context.js
CHANGED
|
@@ -23,10 +23,14 @@ Usage:
|
|
|
23
23
|
|
|
24
24
|
Pack install:
|
|
25
25
|
ctx pack install <packId> [--repo-root <path>] [--mode SkipExisting|Overwrite]
|
|
26
|
+
[--install-option KEY=VALUE] ...
|
|
26
27
|
([--zip <path>] | [--registry <url> [--version <x.y.z>] --token <token>])
|
|
27
28
|
|
|
29
|
+
Install options are pack-specific (e.g. --install-option Flavour=ReviewOnly). See the pack's INSTALLATION.md for supported options.
|
|
30
|
+
|
|
28
31
|
Examples (local zip test):
|
|
29
32
|
ctx pack install pack-01-documentation-management --zip D:\\packs\\pack-01-documentation-management-v0.1.0.zip
|
|
33
|
+
ctx pack install pack-01-documentation-management --zip <path> --install-option Flavour=ReviewOnly
|
|
30
34
|
|
|
31
35
|
Examples (registry download):
|
|
32
36
|
ctx pack install pack-01-documentation-management --registry https://example.com --token YOURTOKEN
|
|
@@ -737,9 +741,19 @@ async function cmdPackInstall(repoRoot, packId, opts) {
|
|
|
737
741
|
if (!version) version = "0.0.0";
|
|
738
742
|
}
|
|
739
743
|
|
|
740
|
-
// Run installer
|
|
741
|
-
|
|
742
|
-
const
|
|
744
|
+
// Run installer: fixed args + pack-specific install options (passed through as -Key "Value")
|
|
745
|
+
const installOpts = opts.installOptions || [];
|
|
746
|
+
const escapePsQuoted = (s) => (s || "").replace(/`/g, "``").replace(/"/g, '`"');
|
|
747
|
+
let installArgs = `-TargetRoot "${escapePsQuoted(repoRoot)}" -PackId "${escapePsQuoted(packId)}" -Mode "${mode}"`;
|
|
748
|
+
for (const pair of installOpts) {
|
|
749
|
+
const eq = pair.indexOf("=");
|
|
750
|
+
const key = pair.slice(0, eq).trim();
|
|
751
|
+
const value = (pair.slice(eq + 1) || "").trim();
|
|
752
|
+
const psKey = toPascalCase(key);
|
|
753
|
+
installArgs += ` -${psKey} "${escapePsQuoted(value)}"`;
|
|
754
|
+
}
|
|
755
|
+
console.log(`Installing (mode=${mode}${installOpts.length ? ", " + installOpts.length + " install option(s)" : ""})...`);
|
|
756
|
+
const installCmd = `& "${escapePsQuoted(installer)}" ${installArgs}`;
|
|
743
757
|
runPwsh(installCmd, { cwd: extractDir });
|
|
744
758
|
|
|
745
759
|
// Ensure docs/local/ exists and .gitignore has /docs/local/
|
|
@@ -777,8 +791,17 @@ async function cmdPackInstall(repoRoot, packId, opts) {
|
|
|
777
791
|
}
|
|
778
792
|
}
|
|
779
793
|
|
|
794
|
+
/** Convert install-option key to PowerShell PascalCase param name (e.g. flavour -> Flavour, some-key -> SomeKey). */
|
|
795
|
+
function toPascalCase(key) {
|
|
796
|
+
if (!key || typeof key !== "string") return key;
|
|
797
|
+
return key
|
|
798
|
+
.split(/[-_]/)
|
|
799
|
+
.map((s) => (s.charAt(0).toUpperCase() + s.slice(1).toLowerCase()))
|
|
800
|
+
.join("");
|
|
801
|
+
}
|
|
802
|
+
|
|
780
803
|
function parseOpts(args) {
|
|
781
|
-
const opts = {};
|
|
804
|
+
const opts = { installOptions: [] };
|
|
782
805
|
for (let i = 0; i < args.length; i++) {
|
|
783
806
|
const a = args[i];
|
|
784
807
|
if (a === "--token") opts.token = args[++i];
|
|
@@ -787,7 +810,11 @@ function parseOpts(args) {
|
|
|
787
810
|
else if (a === "--zip") opts.zip = args[++i];
|
|
788
811
|
else if (a === "--mode") opts.mode = args[++i];
|
|
789
812
|
else if (a === "--repo-root") opts.repoRoot = args[++i];
|
|
790
|
-
else
|
|
813
|
+
else if (a === "--install-option") {
|
|
814
|
+
const pair = args[++i];
|
|
815
|
+
if (!pair || !pair.includes("=")) die("--install-option requires KEY=VALUE (e.g. Flavour=ReviewOnly)");
|
|
816
|
+
opts.installOptions.push(pair);
|
|
817
|
+
} else die(`Unknown option: ${a}`);
|
|
791
818
|
}
|
|
792
819
|
return opts;
|
|
793
820
|
}
|
|
@@ -800,7 +827,7 @@ async function main() {
|
|
|
800
827
|
|
|
801
828
|
if (cmd === "--version" || cmd === "-v" || cmd === "version") {
|
|
802
829
|
// Make sure package.json has version (or hardcode a constant)
|
|
803
|
-
console.log("0.1.
|
|
830
|
+
console.log("0.1.7");
|
|
804
831
|
return;
|
|
805
832
|
}
|
|
806
833
|
|
|
@@ -813,7 +840,7 @@ async function main() {
|
|
|
813
840
|
}
|
|
814
841
|
|
|
815
842
|
const packId = process.argv[4];
|
|
816
|
-
if (!packId) die("Usage: ctx pack install <packId> [--zip <path>] | [--registry <url> --token <token> ...]");
|
|
843
|
+
if (!packId) die("Usage: ctx pack install <packId> [--zip <path>] [--install-option KEY=VALUE ...] | [--registry <url> --token <token> ...]");
|
|
817
844
|
|
|
818
845
|
const opts = parseOpts(process.argv.slice(5));
|
|
819
846
|
|