@kelceyp/caw 1.0.26 → 1.0.28
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/dist/caw.js +352 -103
- package/package.json +1 -1
- package/scripts/postinstall.js +11 -5
package/dist/caw.js
CHANGED
|
@@ -7747,8 +7747,8 @@ var require_constants = __commonJS((exports, module) => {
|
|
|
7747
7747
|
|
|
7748
7748
|
// node_modules/semver/internal/debug.js
|
|
7749
7749
|
var require_debug = __commonJS((exports, module) => {
|
|
7750
|
-
var
|
|
7751
|
-
module.exports =
|
|
7750
|
+
var debug2 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
7751
|
+
module.exports = debug2;
|
|
7752
7752
|
});
|
|
7753
7753
|
|
|
7754
7754
|
// node_modules/semver/internal/re.js
|
|
@@ -7758,7 +7758,7 @@ var require_re = __commonJS((exports, module) => {
|
|
|
7758
7758
|
MAX_SAFE_BUILD_LENGTH,
|
|
7759
7759
|
MAX_LENGTH
|
|
7760
7760
|
} = require_constants();
|
|
7761
|
-
var
|
|
7761
|
+
var debug2 = require_debug();
|
|
7762
7762
|
exports = module.exports = {};
|
|
7763
7763
|
var re = exports.re = [];
|
|
7764
7764
|
var safeRe = exports.safeRe = [];
|
|
@@ -7781,7 +7781,7 @@ var require_re = __commonJS((exports, module) => {
|
|
|
7781
7781
|
var createToken = (name, value, isGlobal) => {
|
|
7782
7782
|
const safe = makeSafeRegex(value);
|
|
7783
7783
|
const index = R++;
|
|
7784
|
-
|
|
7784
|
+
debug2(name, index, value);
|
|
7785
7785
|
t[name] = index;
|
|
7786
7786
|
src[index] = value;
|
|
7787
7787
|
safeSrc[index] = safe;
|
|
@@ -7876,7 +7876,7 @@ var require_identifiers = __commonJS((exports, module) => {
|
|
|
7876
7876
|
|
|
7877
7877
|
// node_modules/semver/classes/semver.js
|
|
7878
7878
|
var require_semver = __commonJS((exports, module) => {
|
|
7879
|
-
var
|
|
7879
|
+
var debug2 = require_debug();
|
|
7880
7880
|
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
7881
7881
|
var { safeRe: re, t } = require_re();
|
|
7882
7882
|
var parseOptions = require_parse_options();
|
|
@@ -7909,7 +7909,7 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
7909
7909
|
if (version.length > MAX_LENGTH) {
|
|
7910
7910
|
throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
7911
7911
|
}
|
|
7912
|
-
|
|
7912
|
+
debug2("SemVer", version, options);
|
|
7913
7913
|
this.options = options;
|
|
7914
7914
|
this.loose = !!options.loose;
|
|
7915
7915
|
this.includePrerelease = !!options.includePrerelease;
|
|
@@ -7957,7 +7957,7 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
7957
7957
|
return this.version;
|
|
7958
7958
|
}
|
|
7959
7959
|
compare(other) {
|
|
7960
|
-
|
|
7960
|
+
debug2("SemVer.compare", this.version, this.options, other);
|
|
7961
7961
|
if (!(other instanceof SemVer)) {
|
|
7962
7962
|
if (typeof other === "string" && other === this.version) {
|
|
7963
7963
|
return 0;
|
|
@@ -8008,7 +8008,7 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
8008
8008
|
do {
|
|
8009
8009
|
const a = this.prerelease[i];
|
|
8010
8010
|
const b = other.prerelease[i];
|
|
8011
|
-
|
|
8011
|
+
debug2("prerelease compare", i, a, b);
|
|
8012
8012
|
if (a === undefined && b === undefined) {
|
|
8013
8013
|
return 0;
|
|
8014
8014
|
} else if (b === undefined) {
|
|
@@ -8030,7 +8030,7 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
8030
8030
|
do {
|
|
8031
8031
|
const a = this.build[i];
|
|
8032
8032
|
const b = other.build[i];
|
|
8033
|
-
|
|
8033
|
+
debug2("build compare", i, a, b);
|
|
8034
8034
|
if (a === undefined && b === undefined) {
|
|
8035
8035
|
return 0;
|
|
8036
8036
|
} else if (b === undefined) {
|
|
@@ -8615,21 +8615,21 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8615
8615
|
const loose = this.options.loose;
|
|
8616
8616
|
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
8617
8617
|
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
8618
|
-
|
|
8618
|
+
debug2("hyphen replace", range);
|
|
8619
8619
|
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
8620
|
-
|
|
8620
|
+
debug2("comparator trim", range);
|
|
8621
8621
|
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
8622
|
-
|
|
8622
|
+
debug2("tilde trim", range);
|
|
8623
8623
|
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
8624
|
-
|
|
8624
|
+
debug2("caret trim", range);
|
|
8625
8625
|
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
8626
8626
|
if (loose) {
|
|
8627
8627
|
rangeList = rangeList.filter((comp) => {
|
|
8628
|
-
|
|
8628
|
+
debug2("loose invalid filter", comp, this.options);
|
|
8629
8629
|
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
8630
8630
|
});
|
|
8631
8631
|
}
|
|
8632
|
-
|
|
8632
|
+
debug2("range list", rangeList);
|
|
8633
8633
|
const rangeMap = new Map;
|
|
8634
8634
|
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
8635
8635
|
for (const comp of comparators) {
|
|
@@ -8683,7 +8683,7 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8683
8683
|
var cache = new LRU;
|
|
8684
8684
|
var parseOptions = require_parse_options();
|
|
8685
8685
|
var Comparator = require_comparator();
|
|
8686
|
-
var
|
|
8686
|
+
var debug2 = require_debug();
|
|
8687
8687
|
var SemVer = require_semver();
|
|
8688
8688
|
var {
|
|
8689
8689
|
safeRe: re,
|
|
@@ -8711,15 +8711,15 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8711
8711
|
};
|
|
8712
8712
|
var parseComparator = (comp, options) => {
|
|
8713
8713
|
comp = comp.replace(re[t.BUILD], "");
|
|
8714
|
-
|
|
8714
|
+
debug2("comp", comp, options);
|
|
8715
8715
|
comp = replaceCarets(comp, options);
|
|
8716
|
-
|
|
8716
|
+
debug2("caret", comp);
|
|
8717
8717
|
comp = replaceTildes(comp, options);
|
|
8718
|
-
|
|
8718
|
+
debug2("tildes", comp);
|
|
8719
8719
|
comp = replaceXRanges(comp, options);
|
|
8720
|
-
|
|
8720
|
+
debug2("xrange", comp);
|
|
8721
8721
|
comp = replaceStars(comp, options);
|
|
8722
|
-
|
|
8722
|
+
debug2("stars", comp);
|
|
8723
8723
|
return comp;
|
|
8724
8724
|
};
|
|
8725
8725
|
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
@@ -8730,7 +8730,7 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8730
8730
|
var replaceTilde = (comp, options) => {
|
|
8731
8731
|
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
8732
8732
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
8733
|
-
|
|
8733
|
+
debug2("tilde", comp, _, M, m, p, pr);
|
|
8734
8734
|
let ret;
|
|
8735
8735
|
if (isX(M)) {
|
|
8736
8736
|
ret = "";
|
|
@@ -8739,12 +8739,12 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8739
8739
|
} else if (isX(p)) {
|
|
8740
8740
|
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
8741
8741
|
} else if (pr) {
|
|
8742
|
-
|
|
8742
|
+
debug2("replaceTilde pr", pr);
|
|
8743
8743
|
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
8744
8744
|
} else {
|
|
8745
8745
|
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
8746
8746
|
}
|
|
8747
|
-
|
|
8747
|
+
debug2("tilde return", ret);
|
|
8748
8748
|
return ret;
|
|
8749
8749
|
});
|
|
8750
8750
|
};
|
|
@@ -8752,11 +8752,11 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8752
8752
|
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
8753
8753
|
};
|
|
8754
8754
|
var replaceCaret = (comp, options) => {
|
|
8755
|
-
|
|
8755
|
+
debug2("caret", comp, options);
|
|
8756
8756
|
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
8757
8757
|
const z = options.includePrerelease ? "-0" : "";
|
|
8758
8758
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
8759
|
-
|
|
8759
|
+
debug2("caret", comp, _, M, m, p, pr);
|
|
8760
8760
|
let ret;
|
|
8761
8761
|
if (isX(M)) {
|
|
8762
8762
|
ret = "";
|
|
@@ -8769,7 +8769,7 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8769
8769
|
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
8770
8770
|
}
|
|
8771
8771
|
} else if (pr) {
|
|
8772
|
-
|
|
8772
|
+
debug2("replaceCaret pr", pr);
|
|
8773
8773
|
if (M === "0") {
|
|
8774
8774
|
if (m === "0") {
|
|
8775
8775
|
ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
@@ -8780,7 +8780,7 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8780
8780
|
ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
8781
8781
|
}
|
|
8782
8782
|
} else {
|
|
8783
|
-
|
|
8783
|
+
debug2("no pr");
|
|
8784
8784
|
if (M === "0") {
|
|
8785
8785
|
if (m === "0") {
|
|
8786
8786
|
ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
|
|
@@ -8791,19 +8791,19 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8791
8791
|
ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
8792
8792
|
}
|
|
8793
8793
|
}
|
|
8794
|
-
|
|
8794
|
+
debug2("caret return", ret);
|
|
8795
8795
|
return ret;
|
|
8796
8796
|
});
|
|
8797
8797
|
};
|
|
8798
8798
|
var replaceXRanges = (comp, options) => {
|
|
8799
|
-
|
|
8799
|
+
debug2("replaceXRanges", comp, options);
|
|
8800
8800
|
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
8801
8801
|
};
|
|
8802
8802
|
var replaceXRange = (comp, options) => {
|
|
8803
8803
|
comp = comp.trim();
|
|
8804
8804
|
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
8805
8805
|
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
8806
|
-
|
|
8806
|
+
debug2("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
8807
8807
|
if (invalidXRangeOrder(M, m, p)) {
|
|
8808
8808
|
return comp;
|
|
8809
8809
|
}
|
|
@@ -8853,16 +8853,16 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8853
8853
|
} else if (xp) {
|
|
8854
8854
|
ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
8855
8855
|
}
|
|
8856
|
-
|
|
8856
|
+
debug2("xRange return", ret);
|
|
8857
8857
|
return ret;
|
|
8858
8858
|
});
|
|
8859
8859
|
};
|
|
8860
8860
|
var replaceStars = (comp, options) => {
|
|
8861
|
-
|
|
8861
|
+
debug2("replaceStars", comp, options);
|
|
8862
8862
|
return comp.trim().replace(re[t.STAR], "");
|
|
8863
8863
|
};
|
|
8864
8864
|
var replaceGTE0 = (comp, options) => {
|
|
8865
|
-
|
|
8865
|
+
debug2("replaceGTE0", comp, options);
|
|
8866
8866
|
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
8867
8867
|
};
|
|
8868
8868
|
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
@@ -8900,7 +8900,7 @@ var require_range = __commonJS((exports, module) => {
|
|
|
8900
8900
|
}
|
|
8901
8901
|
if (version.prerelease.length && !options.includePrerelease) {
|
|
8902
8902
|
for (let i = 0;i < set.length; i++) {
|
|
8903
|
-
|
|
8903
|
+
debug2(set[i].semver);
|
|
8904
8904
|
if (set[i].semver === Comparator.ANY) {
|
|
8905
8905
|
continue;
|
|
8906
8906
|
}
|
|
@@ -8935,7 +8935,7 @@ var require_comparator = __commonJS((exports, module) => {
|
|
|
8935
8935
|
}
|
|
8936
8936
|
}
|
|
8937
8937
|
comp = comp.trim().split(/\s+/).join(" ");
|
|
8938
|
-
|
|
8938
|
+
debug2("comparator", comp, options);
|
|
8939
8939
|
this.options = options;
|
|
8940
8940
|
this.loose = !!options.loose;
|
|
8941
8941
|
this.parse(comp);
|
|
@@ -8944,7 +8944,7 @@ var require_comparator = __commonJS((exports, module) => {
|
|
|
8944
8944
|
} else {
|
|
8945
8945
|
this.value = this.operator + this.semver.version;
|
|
8946
8946
|
}
|
|
8947
|
-
|
|
8947
|
+
debug2("comp", this);
|
|
8948
8948
|
}
|
|
8949
8949
|
parse(comp) {
|
|
8950
8950
|
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
@@ -8966,7 +8966,7 @@ var require_comparator = __commonJS((exports, module) => {
|
|
|
8966
8966
|
return this.value;
|
|
8967
8967
|
}
|
|
8968
8968
|
test(version) {
|
|
8969
|
-
|
|
8969
|
+
debug2("Comparator.test", version, this.options.loose);
|
|
8970
8970
|
if (this.semver === ANY || version === ANY) {
|
|
8971
8971
|
return true;
|
|
8972
8972
|
}
|
|
@@ -9023,7 +9023,7 @@ var require_comparator = __commonJS((exports, module) => {
|
|
|
9023
9023
|
var parseOptions = require_parse_options();
|
|
9024
9024
|
var { safeRe: re, t } = require_re();
|
|
9025
9025
|
var cmp = require_cmp();
|
|
9026
|
-
var
|
|
9026
|
+
var debug2 = require_debug();
|
|
9027
9027
|
var SemVer = require_semver();
|
|
9028
9028
|
var Range = require_range();
|
|
9029
9029
|
});
|
|
@@ -10494,16 +10494,39 @@ var globalHandlerRegistry = new Map;
|
|
|
10494
10494
|
import fs2 from "node:fs";
|
|
10495
10495
|
import path from "node:path";
|
|
10496
10496
|
import { execSync } from "node:child_process";
|
|
10497
|
-
var
|
|
10497
|
+
var EXIT_PLATFORM = 100;
|
|
10498
|
+
var EXIT_ARCH = 101;
|
|
10499
|
+
var EXIT_NODE = 102;
|
|
10500
|
+
var EXIT_ROOT = 103;
|
|
10501
|
+
var EXIT_WRITABLE = 104;
|
|
10502
|
+
var INSTALL_GUIDE_URL = "https://athenadesign.com.au/caw/installation-guide";
|
|
10503
|
+
var GUIDE_TAIL = `See ${INSTALL_GUIDE_URL} for the full walkthrough.`;
|
|
10498
10504
|
function buildPrefixWritableMessage(prefix) {
|
|
10499
|
-
return `
|
|
10500
|
-
` + `
|
|
10505
|
+
return `caw: writable preflight check failed.
|
|
10506
|
+
` + `The npm global prefix is not writable.
|
|
10501
10507
|
|
|
10502
|
-
` + `
|
|
10503
|
-
` + `
|
|
10504
|
-
|
|
10505
|
-
` +
|
|
10506
|
-
|
|
10508
|
+
` + `sudo npm install -g @kelceyp/caw-server@latest
|
|
10509
|
+
` + `(and, if the target server needs a newer launcher: sudo npm install -g @kelceyp/caw@latest)
|
|
10510
|
+
|
|
10511
|
+
` + `${GUIDE_TAIL}
|
|
10512
|
+
|
|
10513
|
+
` + `Observed prefix: ${prefix}
|
|
10514
|
+
` + `Note: sudo may resolve a different Node than your login shell — compare \`node --version\` with \`sudo node --version\` before running.`;
|
|
10515
|
+
}
|
|
10516
|
+
function checkNodeVersion() {
|
|
10517
|
+
const major = parseInt(process.versions.node.split(".")[0], 10);
|
|
10518
|
+
if (major >= 24) {
|
|
10519
|
+
return { ok: true, message: null };
|
|
10520
|
+
}
|
|
10521
|
+
const message = `caw: node preflight check failed.
|
|
10522
|
+
` + `caw requires Node.js 24 or later.
|
|
10523
|
+
|
|
10524
|
+
` + `Install Node.js 24 or later (nvm is the recommended path to a user-owned Node).
|
|
10525
|
+
|
|
10526
|
+
` + `${GUIDE_TAIL}
|
|
10527
|
+
|
|
10528
|
+
` + `Observed Node: ${process.version}`;
|
|
10529
|
+
return { ok: false, message };
|
|
10507
10530
|
}
|
|
10508
10531
|
function checkGlobalInstall() {
|
|
10509
10532
|
const scriptPath = process.argv[1];
|
|
@@ -10559,6 +10582,80 @@ function checkPrefixWritable() {
|
|
|
10559
10582
|
};
|
|
10560
10583
|
}
|
|
10561
10584
|
}
|
|
10585
|
+
function checkPlatform() {
|
|
10586
|
+
if (process.platform === "darwin") {
|
|
10587
|
+
return { ok: true, message: null };
|
|
10588
|
+
}
|
|
10589
|
+
const message = `caw: platform preflight check failed.
|
|
10590
|
+
` + `caw supports macOS only.
|
|
10591
|
+
|
|
10592
|
+
` + `Install caw on a macOS (darwin) host.
|
|
10593
|
+
|
|
10594
|
+
` + `${GUIDE_TAIL}
|
|
10595
|
+
|
|
10596
|
+
` + `Observed platform: ${process.platform}`;
|
|
10597
|
+
return { ok: false, message };
|
|
10598
|
+
}
|
|
10599
|
+
function checkArch() {
|
|
10600
|
+
if (process.arch === "x64" || process.arch === "arm64") {
|
|
10601
|
+
return { ok: true, message: null };
|
|
10602
|
+
}
|
|
10603
|
+
const message = `caw: arch preflight check failed.
|
|
10604
|
+
` + `caw supports x64 (Intel) and arm64 (Apple Silicon) only.
|
|
10605
|
+
|
|
10606
|
+
` + `Install caw on a supported architecture.
|
|
10607
|
+
|
|
10608
|
+
` + `${GUIDE_TAIL}
|
|
10609
|
+
|
|
10610
|
+
` + `Observed arch: ${process.arch}`;
|
|
10611
|
+
return { ok: false, message };
|
|
10612
|
+
}
|
|
10613
|
+
function checkNotRoot() {
|
|
10614
|
+
const uid = process.getuid?.();
|
|
10615
|
+
if (uid !== 0) {
|
|
10616
|
+
return { ok: true, message: null };
|
|
10617
|
+
}
|
|
10618
|
+
const message = `caw: not-root preflight check failed.
|
|
10619
|
+
` + `Refusing to run as root — this command must not be invoked under sudo.
|
|
10620
|
+
|
|
10621
|
+
` + `Re-run the command without sudo.
|
|
10622
|
+
|
|
10623
|
+
` + `${GUIDE_TAIL}`;
|
|
10624
|
+
return { ok: false, message };
|
|
10625
|
+
}
|
|
10626
|
+
function runInstallPreflight({ requireNotRoot }) {
|
|
10627
|
+
const platform = checkPlatform();
|
|
10628
|
+
if (!platform.ok) {
|
|
10629
|
+
return { ok: false, failedGate: "platform", message: platform.message, exitCode: EXIT_PLATFORM };
|
|
10630
|
+
}
|
|
10631
|
+
const arch = checkArch();
|
|
10632
|
+
if (!arch.ok) {
|
|
10633
|
+
return { ok: false, failedGate: "arch", message: arch.message, exitCode: EXIT_ARCH };
|
|
10634
|
+
}
|
|
10635
|
+
const node = checkNodeVersion();
|
|
10636
|
+
if (!node.ok) {
|
|
10637
|
+
return { ok: false, failedGate: "node", message: node.message, exitCode: EXIT_NODE };
|
|
10638
|
+
}
|
|
10639
|
+
if (requireNotRoot) {
|
|
10640
|
+
const notRoot = checkNotRoot();
|
|
10641
|
+
if (!notRoot.ok) {
|
|
10642
|
+
return { ok: false, failedGate: "root", message: notRoot.message, exitCode: EXIT_ROOT };
|
|
10643
|
+
}
|
|
10644
|
+
}
|
|
10645
|
+
const writable = checkPrefixWritable();
|
|
10646
|
+
if (!writable.ok) {
|
|
10647
|
+
return { ok: false, failedGate: "writable", message: writable.message, exitCode: EXIT_WRITABLE };
|
|
10648
|
+
}
|
|
10649
|
+
return { ok: true, failedGate: null, message: null };
|
|
10650
|
+
}
|
|
10651
|
+
function emitPreflightFailure(result, { warnOnly = false } = {}) {
|
|
10652
|
+
if (warnOnly) {
|
|
10653
|
+
console.log(result.message);
|
|
10654
|
+
return;
|
|
10655
|
+
}
|
|
10656
|
+
console.error(result.message);
|
|
10657
|
+
process.exit(result.exitCode);
|
|
10658
|
+
}
|
|
10562
10659
|
|
|
10563
10660
|
// src/server-info.js
|
|
10564
10661
|
import fs3 from "node:fs";
|
|
@@ -10684,6 +10781,7 @@ function resolve(overrideBinPath) {
|
|
|
10684
10781
|
import fs6 from "node:fs";
|
|
10685
10782
|
import path6 from "node:path";
|
|
10686
10783
|
import os2 from "node:os";
|
|
10784
|
+
import crypto from "node:crypto";
|
|
10687
10785
|
import { execSync as execSync4 } from "node:child_process";
|
|
10688
10786
|
|
|
10689
10787
|
// src/config.js
|
|
@@ -10697,7 +10795,8 @@ var DEFAULTS = Object.freeze({
|
|
|
10697
10795
|
caddy: Object.freeze({
|
|
10698
10796
|
enabled: false,
|
|
10699
10797
|
domain: "caw.localhost"
|
|
10700
|
-
})
|
|
10798
|
+
}),
|
|
10799
|
+
analyticsEnabled: true
|
|
10701
10800
|
});
|
|
10702
10801
|
function configPath(envDir) {
|
|
10703
10802
|
return path4.join(envDir, CONFIG_FILENAME);
|
|
@@ -10945,6 +11044,87 @@ async function waitForExit(pm, intervalMs, maxWaitMs) {
|
|
|
10945
11044
|
return false;
|
|
10946
11045
|
}
|
|
10947
11046
|
|
|
11047
|
+
// src/analytics.js
|
|
11048
|
+
var DEFAULT_HOST = "https://us.i.posthog.com";
|
|
11049
|
+
var TIMEOUT_MS = 3000;
|
|
11050
|
+
var DEBUG_NS = "caw:launcher:analytics";
|
|
11051
|
+
var TIMEOUT_SENTINEL = Symbol("timeout");
|
|
11052
|
+
function debug(fmt, ...args) {
|
|
11053
|
+
const dbg = process.env.DEBUG;
|
|
11054
|
+
if (!dbg)
|
|
11055
|
+
return;
|
|
11056
|
+
const patterns = dbg.split(/[\s,]+/).filter(Boolean);
|
|
11057
|
+
const matches = patterns.some((p) => {
|
|
11058
|
+
const escaped = p.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
11059
|
+
const re = new RegExp("^" + escaped + "$");
|
|
11060
|
+
return re.test(DEBUG_NS) || re.test(DEBUG_NS + ":debug");
|
|
11061
|
+
});
|
|
11062
|
+
if (!matches)
|
|
11063
|
+
return;
|
|
11064
|
+
const msg = fmt.replace(/%s|%d/g, () => String(args.shift()));
|
|
11065
|
+
process.stderr.write(`${DEBUG_NS}:debug ${msg}
|
|
11066
|
+
`);
|
|
11067
|
+
}
|
|
11068
|
+
function resolveApiKey() {
|
|
11069
|
+
return process.env.POSTHOG_API_KEY ?? null;
|
|
11070
|
+
}
|
|
11071
|
+
function launcherVersion() {
|
|
11072
|
+
try {
|
|
11073
|
+
return resolvePackageVersion({ importMetaUrl: import.meta.url, packageName: "@kelceyp/caw" }).version;
|
|
11074
|
+
} catch {
|
|
11075
|
+
return null;
|
|
11076
|
+
}
|
|
11077
|
+
}
|
|
11078
|
+
async function emitCawCmd({ op, config }) {
|
|
11079
|
+
if (config?.analyticsEnabled !== true)
|
|
11080
|
+
return;
|
|
11081
|
+
const installId = config.installId;
|
|
11082
|
+
if (typeof installId !== "string" || installId.length === 0)
|
|
11083
|
+
return;
|
|
11084
|
+
const apiKey = resolveApiKey();
|
|
11085
|
+
if (apiKey === null)
|
|
11086
|
+
return;
|
|
11087
|
+
const host = process.env.POSTHOG_HOST || DEFAULT_HOST;
|
|
11088
|
+
const properties = { op };
|
|
11089
|
+
if (op === "start") {
|
|
11090
|
+
properties.$set = {
|
|
11091
|
+
launcher_version: launcherVersion(),
|
|
11092
|
+
os: process.platform,
|
|
11093
|
+
arch: process.arch
|
|
11094
|
+
};
|
|
11095
|
+
}
|
|
11096
|
+
const body = {
|
|
11097
|
+
api_key: apiKey,
|
|
11098
|
+
event: "caw cmd",
|
|
11099
|
+
distinct_id: installId,
|
|
11100
|
+
properties,
|
|
11101
|
+
timestamp: new Date().toISOString()
|
|
11102
|
+
};
|
|
11103
|
+
try {
|
|
11104
|
+
const timer = new Promise((resolve2) => setTimeout(() => resolve2(TIMEOUT_SENTINEL), TIMEOUT_MS));
|
|
11105
|
+
const req = fetch(`${host}/capture/`, {
|
|
11106
|
+
method: "POST",
|
|
11107
|
+
headers: { "Content-Type": "application/json" },
|
|
11108
|
+
body: JSON.stringify(body)
|
|
11109
|
+
});
|
|
11110
|
+
const res = await Promise.race([req, timer]);
|
|
11111
|
+
if (res === TIMEOUT_SENTINEL) {
|
|
11112
|
+
debug("emit timeout op=%s path=/capture/", op);
|
|
11113
|
+
return;
|
|
11114
|
+
}
|
|
11115
|
+
if (!res.ok)
|
|
11116
|
+
debug("emit non-2xx op=%s status=%d path=/capture/", op, res.status);
|
|
11117
|
+
} catch (err) {
|
|
11118
|
+
debug("emit failed op=%s err=%s path=/capture/", op, err?.message ?? err);
|
|
11119
|
+
}
|
|
11120
|
+
}
|
|
11121
|
+
async function emitCawCmdStart({ config }) {
|
|
11122
|
+
return emitCawCmd({ op: "start", config });
|
|
11123
|
+
}
|
|
11124
|
+
async function emitCawCmdStop({ config }) {
|
|
11125
|
+
return emitCawCmd({ op: "stop", config });
|
|
11126
|
+
}
|
|
11127
|
+
|
|
10948
11128
|
// src/commands/start.js
|
|
10949
11129
|
function resolveEnvDir(rawEnvDir) {
|
|
10950
11130
|
if (rawEnvDir.startsWith("~")) {
|
|
@@ -11017,10 +11197,72 @@ function buildEnvNodeArgs(envDir) {
|
|
|
11017
11197
|
const envFilePath = path6.join(envDir, ".env");
|
|
11018
11198
|
return [`--env-file=${envFilePath}`];
|
|
11019
11199
|
}
|
|
11200
|
+
function sleepSync(ms) {
|
|
11201
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
11202
|
+
}
|
|
11203
|
+
function hasFullIdentity(config) {
|
|
11204
|
+
return typeof config?.installId === "string" && config.installId.length > 0 && typeof config?.installSalt === "string" && config.installSalt.length > 0 && typeof config?.analyticsEnabled === "boolean";
|
|
11205
|
+
}
|
|
11206
|
+
function ensureInstallIdentity(envDir) {
|
|
11207
|
+
if (configExists(envDir)) {
|
|
11208
|
+
const existing = readConfig(envDir);
|
|
11209
|
+
if (hasFullIdentity(existing))
|
|
11210
|
+
return existing;
|
|
11211
|
+
}
|
|
11212
|
+
fs6.mkdirSync(envDir, { recursive: true });
|
|
11213
|
+
const lockPath = path6.join(envDir, "config.identity.lock");
|
|
11214
|
+
let acquired = false;
|
|
11215
|
+
for (let attempt = 0;attempt < 100; attempt++) {
|
|
11216
|
+
try {
|
|
11217
|
+
const fd = fs6.openSync(lockPath, "wx");
|
|
11218
|
+
fs6.closeSync(fd);
|
|
11219
|
+
acquired = true;
|
|
11220
|
+
break;
|
|
11221
|
+
} catch (e) {
|
|
11222
|
+
if (e.code !== "EEXIST")
|
|
11223
|
+
throw e;
|
|
11224
|
+
try {
|
|
11225
|
+
const st = fs6.statSync(lockPath);
|
|
11226
|
+
if (Date.now() - st.mtimeMs > 1e4) {
|
|
11227
|
+
fs6.unlinkSync(lockPath);
|
|
11228
|
+
continue;
|
|
11229
|
+
}
|
|
11230
|
+
} catch {}
|
|
11231
|
+
sleepSync(50);
|
|
11232
|
+
}
|
|
11233
|
+
}
|
|
11234
|
+
try {
|
|
11235
|
+
const existing = configExists(envDir) ? readConfig(envDir) : { ...DEFAULTS };
|
|
11236
|
+
const merged = { ...existing };
|
|
11237
|
+
let mutated = false;
|
|
11238
|
+
if (typeof merged.installId !== "string" || merged.installId.length === 0) {
|
|
11239
|
+
merged.installId = crypto.randomUUID();
|
|
11240
|
+
mutated = true;
|
|
11241
|
+
}
|
|
11242
|
+
if (typeof merged.installSalt !== "string" || merged.installSalt.length === 0) {
|
|
11243
|
+
merged.installSalt = crypto.randomBytes(32).toString("base64url");
|
|
11244
|
+
mutated = true;
|
|
11245
|
+
}
|
|
11246
|
+
if (typeof merged.analyticsEnabled !== "boolean") {
|
|
11247
|
+
merged.analyticsEnabled = DEFAULTS.analyticsEnabled;
|
|
11248
|
+
mutated = true;
|
|
11249
|
+
}
|
|
11250
|
+
if (mutated) {
|
|
11251
|
+
writeConfig(envDir, merged);
|
|
11252
|
+
}
|
|
11253
|
+
return readConfig(envDir);
|
|
11254
|
+
} finally {
|
|
11255
|
+
if (acquired) {
|
|
11256
|
+
try {
|
|
11257
|
+
fs6.unlinkSync(lockPath);
|
|
11258
|
+
} catch {}
|
|
11259
|
+
}
|
|
11260
|
+
}
|
|
11261
|
+
}
|
|
11020
11262
|
function bootstrap(envDir) {
|
|
11021
11263
|
fs6.mkdirSync(envDir, { recursive: true });
|
|
11022
11264
|
fs6.mkdirSync(path6.join(envDir, "assets"), { recursive: true });
|
|
11023
|
-
|
|
11265
|
+
ensureInstallIdentity(envDir);
|
|
11024
11266
|
const envFilePath = path6.join(envDir, ".env");
|
|
11025
11267
|
if (!fs6.existsSync(envFilePath)) {
|
|
11026
11268
|
fs6.writeFileSync(envFilePath, [
|
|
@@ -11071,6 +11313,11 @@ async function pollHealth(port, maxRetries = 10, intervalMs = 1000) {
|
|
|
11071
11313
|
return false;
|
|
11072
11314
|
}
|
|
11073
11315
|
function attemptInstallServer() {
|
|
11316
|
+
const preflight = runInstallPreflight({ requireNotRoot: true });
|
|
11317
|
+
if (!preflight.ok) {
|
|
11318
|
+
emitPreflightFailure(preflight);
|
|
11319
|
+
return false;
|
|
11320
|
+
}
|
|
11074
11321
|
try {
|
|
11075
11322
|
execSync4("npm install -g @kelceyp/caw-server@^1 --loglevel=error", { stdio: "inherit" });
|
|
11076
11323
|
return true;
|
|
@@ -11080,6 +11327,15 @@ function attemptInstallServer() {
|
|
|
11080
11327
|
}
|
|
11081
11328
|
var create2 = () => {
|
|
11082
11329
|
return createCommand("start").summary("Start the caw server").param((p) => p.name("env-dir").type("string").flag("env-dir").default("~/.caw/")).run(async (ctx) => {
|
|
11330
|
+
const rootCheck = checkNotRoot();
|
|
11331
|
+
if (!rootCheck.ok) {
|
|
11332
|
+
emitPreflightFailure({
|
|
11333
|
+
ok: false,
|
|
11334
|
+
failedGate: "root",
|
|
11335
|
+
message: rootCheck.message,
|
|
11336
|
+
exitCode: EXIT_ROOT
|
|
11337
|
+
});
|
|
11338
|
+
}
|
|
11083
11339
|
const envDir = resolveEnvDir(ctx.params["env-dir"]);
|
|
11084
11340
|
const prefixCheck = checkPrefixWritable();
|
|
11085
11341
|
if (!prefixCheck.ok) {
|
|
@@ -11089,30 +11345,13 @@ var create2 = () => {
|
|
|
11089
11345
|
|
|
11090
11346
|
How would you like to proceed?`,
|
|
11091
11347
|
choices: [
|
|
11092
|
-
{ label: "Continue anyway", value: "continue" },
|
|
11348
|
+
{ label: "Continue anyway (installation will be re-checked; a fresh preflight will refuse if it still fails)", value: "continue" },
|
|
11093
11349
|
{ label: "Switch to nvm (recommended)", value: "nvm" },
|
|
11094
11350
|
{ label: "Exit", value: "exit" }
|
|
11095
11351
|
]
|
|
11096
11352
|
});
|
|
11097
11353
|
if (choice === "nvm") {
|
|
11098
|
-
console.log(`
|
|
11099
|
-
To install nvm and get a user-owned prefix:
|
|
11100
|
-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_INSTALLER_VERSION}/install.sh | bash
|
|
11101
|
-
nvm install 24
|
|
11102
|
-
npm install -g @kelceyp/caw
|
|
11103
|
-
|
|
11104
|
-
For a newer nvm release, check https://github.com/nvm-sh/nvm/releases
|
|
11105
|
-
and substitute the tag into the curl URL above.
|
|
11106
|
-
|
|
11107
|
-
After reloading your shell you may see a \`zsh compinit: insecure
|
|
11108
|
-
directories\` warning — a pre-existing insecure entry on your zsh
|
|
11109
|
-
fpath that compinit surfaces on the next shell (not caused by nvm).
|
|
11110
|
-
To fix:
|
|
11111
|
-
1. Run \`compaudit\` to list offending paths.
|
|
11112
|
-
2. For each path, apply whichever is appropriate:
|
|
11113
|
-
- chmod g-w,o-w <path> (if group/world writable)
|
|
11114
|
-
- chown <you> <path> (if not owned by root or you)
|
|
11115
|
-
Do not blanket-chmod without inspecting compaudit's output.`);
|
|
11354
|
+
console.log(`See ${INSTALL_GUIDE_URL} for the full walkthrough.`);
|
|
11116
11355
|
process.exit(0);
|
|
11117
11356
|
}
|
|
11118
11357
|
if (choice === "exit") {
|
|
@@ -11123,6 +11362,8 @@ To fix:
|
|
|
11123
11362
|
console.log(`Creating environment directory: ${envDir}`);
|
|
11124
11363
|
bootstrap(envDir);
|
|
11125
11364
|
console.log("Wrote default config.json");
|
|
11365
|
+
} else {
|
|
11366
|
+
ensureInstallIdentity(envDir);
|
|
11126
11367
|
}
|
|
11127
11368
|
const config = readConfigWithDefaults(envDir);
|
|
11128
11369
|
const pm = createProcessManager(config, envDir);
|
|
@@ -11142,6 +11383,7 @@ To fix:
|
|
|
11142
11383
|
console.log(`Server is already running on port ${config.port}.`);
|
|
11143
11384
|
process.exit(0);
|
|
11144
11385
|
}
|
|
11386
|
+
await emitCawCmdStart({ config: readConfig(envDir) });
|
|
11145
11387
|
let activeConfig = config;
|
|
11146
11388
|
if (hasPendingConfig(envDir)) {
|
|
11147
11389
|
const active = readConfig(envDir);
|
|
@@ -11181,6 +11423,13 @@ To fix:
|
|
|
11181
11423
|
CAW_PORT: String(activeConfig.port),
|
|
11182
11424
|
CAW_ENV_DIR: envDir
|
|
11183
11425
|
};
|
|
11426
|
+
if (typeof activeConfig.installId === "string" && activeConfig.installId.length > 0 && typeof activeConfig.installSalt === "string" && activeConfig.installSalt.length > 0) {
|
|
11427
|
+
envVars.CAW_INSTALL_ID = String(activeConfig.installId);
|
|
11428
|
+
envVars.CAW_INSTALL_SALT = String(activeConfig.installSalt);
|
|
11429
|
+
}
|
|
11430
|
+
if (typeof activeConfig.analyticsEnabled === "boolean") {
|
|
11431
|
+
envVars.CAW_ANALYTICS_ENABLED = activeConfig.analyticsEnabled ? "true" : "false";
|
|
11432
|
+
}
|
|
11184
11433
|
const nodeArgs = buildEnvNodeArgs(envDir);
|
|
11185
11434
|
const pm2 = createProcessManager(activeConfig, envDir);
|
|
11186
11435
|
const id = pm2.start(serverInfo.mainJsPath, envVars, nodeArgs);
|
|
@@ -11222,9 +11471,10 @@ async function checkHealth2(port) {
|
|
|
11222
11471
|
return { reachable: false, healthy: false, data: null };
|
|
11223
11472
|
}
|
|
11224
11473
|
}
|
|
11225
|
-
async function executeStop(pm, config, force, promptFn) {
|
|
11474
|
+
async function executeStop(pm, config, force, promptFn, envDir) {
|
|
11226
11475
|
const runState = pm.isRunning();
|
|
11227
11476
|
if (!runState.running) {
|
|
11477
|
+
await emitCawCmdStop({ config: envDir ? readConfig(envDir) : config });
|
|
11228
11478
|
return { stopped: false, wasRunning: false };
|
|
11229
11479
|
}
|
|
11230
11480
|
const health = await checkHealth2(config.port);
|
|
@@ -11254,6 +11504,7 @@ async function executeStop(pm, config, force, promptFn) {
|
|
|
11254
11504
|
if (exited) {
|
|
11255
11505
|
pm.cleanup();
|
|
11256
11506
|
console.log("Server stopped.");
|
|
11507
|
+
await emitCawCmdStop({ config: envDir ? readConfig(envDir) : config });
|
|
11257
11508
|
return { stopped: true, wasRunning: true };
|
|
11258
11509
|
}
|
|
11259
11510
|
if (!force) {
|
|
@@ -11266,6 +11517,7 @@ async function executeStop(pm, config, force, promptFn) {
|
|
|
11266
11517
|
pm.cleanup();
|
|
11267
11518
|
if (killed) {
|
|
11268
11519
|
console.log("Server force-killed.");
|
|
11520
|
+
await emitCawCmdStop({ config: envDir ? readConfig(envDir) : config });
|
|
11269
11521
|
return { stopped: true, wasRunning: true };
|
|
11270
11522
|
}
|
|
11271
11523
|
console.error("Server process could not be stopped.");
|
|
@@ -11281,7 +11533,7 @@ var create3 = () => {
|
|
|
11281
11533
|
}
|
|
11282
11534
|
const config = readConfigWithDefaults(envDir);
|
|
11283
11535
|
const pm = createProcessManager(config, envDir);
|
|
11284
|
-
const result = await executeStop(pm, config, force, ctx.prompt);
|
|
11536
|
+
const result = await executeStop(pm, config, force, ctx.prompt, envDir);
|
|
11285
11537
|
if (!result.wasRunning) {
|
|
11286
11538
|
console.log("Server is not running.");
|
|
11287
11539
|
process.exit(0);
|
|
@@ -11559,21 +11811,20 @@ async function pollHealth2(port, maxRetries = 10, intervalMs = 1000) {
|
|
|
11559
11811
|
}
|
|
11560
11812
|
var create6 = () => {
|
|
11561
11813
|
return createCommand("upgrade").summary("Upgrade caw-server to the latest version").param((p) => p.name("env-dir").type("string").flag("env-dir").default("~/.caw/")).param((p) => p.name("force").type("boolean").flag("force").default(false)).run(async (ctx) => {
|
|
11814
|
+
const rootCheck = checkNotRoot();
|
|
11815
|
+
if (!rootCheck.ok) {
|
|
11816
|
+
emitPreflightFailure({
|
|
11817
|
+
ok: false,
|
|
11818
|
+
failedGate: "root",
|
|
11819
|
+
message: rootCheck.message,
|
|
11820
|
+
exitCode: EXIT_ROOT
|
|
11821
|
+
});
|
|
11822
|
+
}
|
|
11562
11823
|
const envDir = resolveEnvDir5(ctx.params["env-dir"]);
|
|
11563
11824
|
const force = ctx.params.force;
|
|
11564
|
-
const
|
|
11565
|
-
if (!
|
|
11566
|
-
|
|
11567
|
-
console.error(`
|
|
11568
|
-
To upgrade with sudo, run:
|
|
11569
|
-
sudo npm install -g @kelceyp/caw-server@latest
|
|
11570
|
-
sudo npm install -g @kelceyp/caw@latest (only if the target server requires a newer launcher)
|
|
11571
|
-
|
|
11572
|
-
Before running sudo, compare \`node --version\` with \`sudo node --version\`.
|
|
11573
|
-
If they differ, sudo resolves a different Node — often an older, system-supplied one — and the packages install for a Node version you are not using.
|
|
11574
|
-
|
|
11575
|
-
The recommended alternative is a user-owned prefix (e.g. via nvm), which removes the need for sudo on every future upgrade.`);
|
|
11576
|
-
process.exit(1);
|
|
11825
|
+
const preflight = runInstallPreflight({ requireNotRoot: true });
|
|
11826
|
+
if (!preflight.ok) {
|
|
11827
|
+
emitPreflightFailure(preflight);
|
|
11577
11828
|
}
|
|
11578
11829
|
const serverInfo = resolve();
|
|
11579
11830
|
if (!serverInfo) {
|
|
@@ -11759,6 +12010,11 @@ function buildChangeSummary2(active, pending) {
|
|
|
11759
12010
|
return changes;
|
|
11760
12011
|
}
|
|
11761
12012
|
function attemptInstallServer2() {
|
|
12013
|
+
const preflight = runInstallPreflight({ requireNotRoot: true });
|
|
12014
|
+
if (!preflight.ok) {
|
|
12015
|
+
emitPreflightFailure(preflight);
|
|
12016
|
+
return false;
|
|
12017
|
+
}
|
|
11762
12018
|
try {
|
|
11763
12019
|
execSync6("npm install -g @kelceyp/caw-server@^1 --loglevel=error", { stdio: "inherit" });
|
|
11764
12020
|
return true;
|
|
@@ -11768,12 +12024,21 @@ function attemptInstallServer2() {
|
|
|
11768
12024
|
}
|
|
11769
12025
|
var create7 = () => {
|
|
11770
12026
|
return createCommand("restart").summary("Restart the caw server (stop then start)").param((p) => p.name("env-dir").type("string").flag("env-dir").default("~/.caw/")).param((p) => p.name("force").type("boolean").flag("force").default(false)).run(async (ctx) => {
|
|
12027
|
+
const rootCheck = checkNotRoot();
|
|
12028
|
+
if (!rootCheck.ok) {
|
|
12029
|
+
emitPreflightFailure({
|
|
12030
|
+
ok: false,
|
|
12031
|
+
failedGate: "root",
|
|
12032
|
+
message: rootCheck.message,
|
|
12033
|
+
exitCode: EXIT_ROOT
|
|
12034
|
+
});
|
|
12035
|
+
}
|
|
11771
12036
|
const envDir = resolveEnvDir6(ctx.params["env-dir"]);
|
|
11772
12037
|
const force = ctx.params.force;
|
|
11773
12038
|
if (fs12.existsSync(envDir) && configExists5(envDir)) {
|
|
11774
12039
|
const config2 = readConfigWithDefaults(envDir);
|
|
11775
12040
|
const pm3 = createProcessManager(config2, envDir);
|
|
11776
|
-
const result = await executeStop(pm3, config2, force, ctx.prompt);
|
|
12041
|
+
const result = await executeStop(pm3, config2, force, ctx.prompt, envDir);
|
|
11777
12042
|
if (result.wasRunning && !result.stopped) {
|
|
11778
12043
|
if (result.userDeclined) {
|
|
11779
12044
|
process.exit(0);
|
|
@@ -11789,30 +12054,13 @@ var create7 = () => {
|
|
|
11789
12054
|
|
|
11790
12055
|
How would you like to proceed?`,
|
|
11791
12056
|
choices: [
|
|
11792
|
-
{ label: "Continue anyway", value: "continue" },
|
|
12057
|
+
{ label: "Continue anyway (installation will be re-checked; a fresh preflight will refuse if it still fails)", value: "continue" },
|
|
11793
12058
|
{ label: "Switch to nvm (recommended)", value: "nvm" },
|
|
11794
12059
|
{ label: "Exit", value: "exit" }
|
|
11795
12060
|
]
|
|
11796
12061
|
});
|
|
11797
12062
|
if (choice === "nvm") {
|
|
11798
|
-
console.log(`
|
|
11799
|
-
To install nvm and get a user-owned prefix:
|
|
11800
|
-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_INSTALLER_VERSION}/install.sh | bash
|
|
11801
|
-
nvm install 24
|
|
11802
|
-
npm install -g @kelceyp/caw
|
|
11803
|
-
|
|
11804
|
-
For a newer nvm release, check https://github.com/nvm-sh/nvm/releases
|
|
11805
|
-
and substitute the tag into the curl URL above.
|
|
11806
|
-
|
|
11807
|
-
After reloading your shell you may see a \`zsh compinit: insecure
|
|
11808
|
-
directories\` warning — a pre-existing insecure entry on your zsh
|
|
11809
|
-
fpath that compinit surfaces on the next shell (not caused by nvm).
|
|
11810
|
-
To fix:
|
|
11811
|
-
1. Run \`compaudit\` to list offending paths.
|
|
11812
|
-
2. For each path, apply whichever is appropriate:
|
|
11813
|
-
- chmod g-w,o-w <path> (if group/world writable)
|
|
11814
|
-
- chown <you> <path> (if not owned by root or you)
|
|
11815
|
-
Do not blanket-chmod without inspecting compaudit's output.`);
|
|
12063
|
+
console.log(`See ${INSTALL_GUIDE_URL} for the full walkthrough.`);
|
|
11816
12064
|
process.exit(0);
|
|
11817
12065
|
}
|
|
11818
12066
|
if (choice === "exit") {
|
|
@@ -11842,6 +12090,7 @@ To fix:
|
|
|
11842
12090
|
console.log(`Server is already running on port ${config.port}.`);
|
|
11843
12091
|
process.exit(0);
|
|
11844
12092
|
}
|
|
12093
|
+
await emitCawCmdStart({ config: readConfig(envDir) });
|
|
11845
12094
|
let activeConfig = config;
|
|
11846
12095
|
if (hasPendingConfig(envDir)) {
|
|
11847
12096
|
const active = readConfig(envDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kelceyp/caw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Unified Web/MCP server with React web app. Provides MD document management, handlebars based templating (documents, prompts and saved searches), user stories including task management and search (rag, fts & metadata with query language). CAW works with any agent that supports MCP but has specific integrations for Claude Code, Codex and Cursor CLI that enable agent orchestration. For humans, think of this as a browser-based reskinning of these tools enabling all prompts and outputs to be captured. For agents, this means that any of these three agents can be used by any other as a \"sub-agent\". And this works recursively to a user configurable depth.",
|
|
6
6
|
"keywords": [
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
|
+
import { runInstallPreflight, emitPreflightFailure } from '../src/guards.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const preflight = runInstallPreflight({ requireNotRoot: false });
|
|
5
|
+
if (!preflight.ok) {
|
|
6
|
+
emitPreflightFailure(preflight, { warnOnly: true });
|
|
7
|
+
} else {
|
|
8
|
+
try {
|
|
9
|
+
execSync('npm install -g @kelceyp/caw-server@^1 --loglevel=error', { stdio: 'inherit' });
|
|
10
|
+
} catch {
|
|
11
|
+
console.warn('Could not install @kelceyp/caw-server automatically.');
|
|
12
|
+
console.warn('Run "caw start" to retry installation.');
|
|
13
|
+
}
|
|
8
14
|
}
|