@westbayberry/dg 1.0.7 → 1.0.9
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/index.mjs +89 -48
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -48,7 +48,8 @@ __export(config_exports, {
|
|
|
48
48
|
});
|
|
49
49
|
import { parseArgs } from "node:util";
|
|
50
50
|
import { readFileSync, existsSync } from "node:fs";
|
|
51
|
-
import { join } from "node:path";
|
|
51
|
+
import { join, dirname } from "node:path";
|
|
52
|
+
import { fileURLToPath } from "node:url";
|
|
52
53
|
import { homedir } from "node:os";
|
|
53
54
|
function loadDgrc() {
|
|
54
55
|
const candidates = [
|
|
@@ -69,8 +70,9 @@ function loadDgrc() {
|
|
|
69
70
|
}
|
|
70
71
|
function getVersion() {
|
|
71
72
|
try {
|
|
73
|
+
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
72
74
|
const pkg = JSON.parse(
|
|
73
|
-
readFileSync(join(
|
|
75
|
+
readFileSync(join(thisDir, "..", "package.json"), "utf-8")
|
|
74
76
|
);
|
|
75
77
|
return pkg.version ?? "1.0.0";
|
|
76
78
|
} catch {
|
|
@@ -308,7 +310,7 @@ function parsePackageSpec(spec) {
|
|
|
308
310
|
};
|
|
309
311
|
}
|
|
310
312
|
async function resolveVersion(spec) {
|
|
311
|
-
return new Promise((
|
|
313
|
+
return new Promise((resolve) => {
|
|
312
314
|
const child = spawn("npm", ["view", spec, "version"], {
|
|
313
315
|
stdio: ["pipe", "pipe", "pipe"]
|
|
314
316
|
});
|
|
@@ -318,20 +320,20 @@ async function resolveVersion(spec) {
|
|
|
318
320
|
});
|
|
319
321
|
const timer = setTimeout(() => {
|
|
320
322
|
child.kill();
|
|
321
|
-
|
|
323
|
+
resolve(null);
|
|
322
324
|
}, 15e3);
|
|
323
325
|
child.on("close", (code) => {
|
|
324
326
|
clearTimeout(timer);
|
|
325
327
|
if (code !== 0) {
|
|
326
|
-
|
|
328
|
+
resolve(null);
|
|
327
329
|
return;
|
|
328
330
|
}
|
|
329
331
|
const version = stdout.trim();
|
|
330
|
-
|
|
332
|
+
resolve(version || null);
|
|
331
333
|
});
|
|
332
334
|
child.on("error", () => {
|
|
333
335
|
clearTimeout(timer);
|
|
334
|
-
|
|
336
|
+
resolve(null);
|
|
335
337
|
});
|
|
336
338
|
});
|
|
337
339
|
}
|
|
@@ -366,13 +368,13 @@ async function resolvePackages(specs) {
|
|
|
366
368
|
return { resolved, failed };
|
|
367
369
|
}
|
|
368
370
|
function runNpm(args) {
|
|
369
|
-
return new Promise((
|
|
371
|
+
return new Promise((resolve) => {
|
|
370
372
|
const child = spawn("npm", args, {
|
|
371
373
|
stdio: "inherit",
|
|
372
374
|
shell: false
|
|
373
375
|
});
|
|
374
|
-
child.on("close", (code) =>
|
|
375
|
-
child.on("error", () =>
|
|
376
|
+
child.on("close", (code) => resolve(code ?? 1));
|
|
377
|
+
child.on("error", () => resolve(1));
|
|
376
378
|
});
|
|
377
379
|
}
|
|
378
380
|
function readBareInstallPackages(cwd2) {
|
|
@@ -3318,7 +3320,7 @@ var require_react_development = __commonJS({
|
|
|
3318
3320
|
var dispatcher = resolveDispatcher();
|
|
3319
3321
|
return dispatcher.useLayoutEffect(create2, deps);
|
|
3320
3322
|
}
|
|
3321
|
-
function
|
|
3323
|
+
function useCallback5(callback, deps) {
|
|
3322
3324
|
var dispatcher = resolveDispatcher();
|
|
3323
3325
|
return dispatcher.useCallback(callback, deps);
|
|
3324
3326
|
}
|
|
@@ -3944,14 +3946,14 @@ var require_react_development = __commonJS({
|
|
|
3944
3946
|
var thenableResult = result;
|
|
3945
3947
|
var wasAwaited = false;
|
|
3946
3948
|
var thenable = {
|
|
3947
|
-
then: function(
|
|
3949
|
+
then: function(resolve, reject) {
|
|
3948
3950
|
wasAwaited = true;
|
|
3949
3951
|
thenableResult.then(function(returnValue2) {
|
|
3950
3952
|
popActScope(prevActScopeDepth);
|
|
3951
3953
|
if (actScopeDepth === 0) {
|
|
3952
|
-
recursivelyFlushAsyncActWork(returnValue2,
|
|
3954
|
+
recursivelyFlushAsyncActWork(returnValue2, resolve, reject);
|
|
3953
3955
|
} else {
|
|
3954
|
-
|
|
3956
|
+
resolve(returnValue2);
|
|
3955
3957
|
}
|
|
3956
3958
|
}, function(error2) {
|
|
3957
3959
|
popActScope(prevActScopeDepth);
|
|
@@ -3981,20 +3983,20 @@ var require_react_development = __commonJS({
|
|
|
3981
3983
|
ReactCurrentActQueue.current = null;
|
|
3982
3984
|
}
|
|
3983
3985
|
var _thenable = {
|
|
3984
|
-
then: function(
|
|
3986
|
+
then: function(resolve, reject) {
|
|
3985
3987
|
if (ReactCurrentActQueue.current === null) {
|
|
3986
3988
|
ReactCurrentActQueue.current = [];
|
|
3987
|
-
recursivelyFlushAsyncActWork(returnValue,
|
|
3989
|
+
recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
|
3988
3990
|
} else {
|
|
3989
|
-
|
|
3991
|
+
resolve(returnValue);
|
|
3990
3992
|
}
|
|
3991
3993
|
}
|
|
3992
3994
|
};
|
|
3993
3995
|
return _thenable;
|
|
3994
3996
|
} else {
|
|
3995
3997
|
var _thenable2 = {
|
|
3996
|
-
then: function(
|
|
3997
|
-
|
|
3998
|
+
then: function(resolve, reject) {
|
|
3999
|
+
resolve(returnValue);
|
|
3998
4000
|
}
|
|
3999
4001
|
};
|
|
4000
4002
|
return _thenable2;
|
|
@@ -4010,7 +4012,7 @@ var require_react_development = __commonJS({
|
|
|
4010
4012
|
actScopeDepth = prevActScopeDepth;
|
|
4011
4013
|
}
|
|
4012
4014
|
}
|
|
4013
|
-
function recursivelyFlushAsyncActWork(returnValue,
|
|
4015
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
|
|
4014
4016
|
{
|
|
4015
4017
|
var queue = ReactCurrentActQueue.current;
|
|
4016
4018
|
if (queue !== null) {
|
|
@@ -4019,16 +4021,16 @@ var require_react_development = __commonJS({
|
|
|
4019
4021
|
enqueueTask(function() {
|
|
4020
4022
|
if (queue.length === 0) {
|
|
4021
4023
|
ReactCurrentActQueue.current = null;
|
|
4022
|
-
|
|
4024
|
+
resolve(returnValue);
|
|
4023
4025
|
} else {
|
|
4024
|
-
recursivelyFlushAsyncActWork(returnValue,
|
|
4026
|
+
recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
|
4025
4027
|
}
|
|
4026
4028
|
});
|
|
4027
4029
|
} catch (error2) {
|
|
4028
4030
|
reject(error2);
|
|
4029
4031
|
}
|
|
4030
4032
|
} else {
|
|
4031
|
-
|
|
4033
|
+
resolve(returnValue);
|
|
4032
4034
|
}
|
|
4033
4035
|
}
|
|
4034
4036
|
}
|
|
@@ -4085,7 +4087,7 @@ var require_react_development = __commonJS({
|
|
|
4085
4087
|
exports.memo = memo;
|
|
4086
4088
|
exports.startTransition = startTransition;
|
|
4087
4089
|
exports.unstable_act = act;
|
|
4088
|
-
exports.useCallback =
|
|
4090
|
+
exports.useCallback = useCallback5;
|
|
4089
4091
|
exports.useContext = useContext7;
|
|
4090
4092
|
exports.useDebugValue = useDebugValue;
|
|
4091
4093
|
exports.useDeferredValue = useDeferredValue;
|
|
@@ -35380,8 +35382,8 @@ var init_ink = __esm({
|
|
|
35380
35382
|
}
|
|
35381
35383
|
}
|
|
35382
35384
|
async waitUntilExit() {
|
|
35383
|
-
this.exitPromise ||= new Promise((
|
|
35384
|
-
this.resolveExitPromise =
|
|
35385
|
+
this.exitPromise ||= new Promise((resolve, reject) => {
|
|
35386
|
+
this.resolveExitPromise = resolve;
|
|
35385
35387
|
this.rejectExitPromise = reject;
|
|
35386
35388
|
});
|
|
35387
35389
|
return this.exitPromise;
|
|
@@ -36083,12 +36085,15 @@ var init_auth = __esm({
|
|
|
36083
36085
|
});
|
|
36084
36086
|
|
|
36085
36087
|
// src/ui/hooks/useLogin.ts
|
|
36086
|
-
function reducer(
|
|
36088
|
+
function reducer(state, action) {
|
|
36087
36089
|
switch (action.type) {
|
|
36088
36090
|
case "ALREADY_LOGGED_IN":
|
|
36089
36091
|
return { phase: "already_logged_in", apiKey: action.apiKey };
|
|
36090
|
-
case "
|
|
36091
|
-
return { phase: "
|
|
36092
|
+
case "SESSION_READY":
|
|
36093
|
+
return { phase: "ready", verifyUrl: action.verifyUrl };
|
|
36094
|
+
case "BROWSER_OPENED":
|
|
36095
|
+
if (state.phase !== "ready") return state;
|
|
36096
|
+
return { phase: "waiting", verifyUrl: state.verifyUrl };
|
|
36092
36097
|
case "AUTH_COMPLETE":
|
|
36093
36098
|
return { phase: "success", email: action.email };
|
|
36094
36099
|
case "AUTH_EXPIRED":
|
|
@@ -36100,10 +36105,11 @@ function reducer(_state, action) {
|
|
|
36100
36105
|
function useLogin() {
|
|
36101
36106
|
const [state, dispatch] = (0, import_react22.useReducer)(reducer, { phase: "creating" });
|
|
36102
36107
|
const started = (0, import_react22.useRef)(false);
|
|
36108
|
+
const sessionRef = (0, import_react22.useRef)(null);
|
|
36109
|
+
const cancelledRef = (0, import_react22.useRef)(false);
|
|
36103
36110
|
(0, import_react22.useEffect)(() => {
|
|
36104
36111
|
if (started.current) return;
|
|
36105
36112
|
started.current = true;
|
|
36106
|
-
let cancelled = false;
|
|
36107
36113
|
(async () => {
|
|
36108
36114
|
try {
|
|
36109
36115
|
const existing = getStoredApiKey();
|
|
@@ -36121,15 +36127,30 @@ function useLogin() {
|
|
|
36121
36127
|
});
|
|
36122
36128
|
return;
|
|
36123
36129
|
}
|
|
36130
|
+
sessionRef.current = session;
|
|
36131
|
+
dispatch({ type: "SESSION_READY", verifyUrl: session.verifyUrl });
|
|
36132
|
+
} catch (err) {
|
|
36124
36133
|
dispatch({
|
|
36125
|
-
type: "
|
|
36126
|
-
|
|
36134
|
+
type: "ERROR",
|
|
36135
|
+
message: err instanceof Error ? err.message : String(err)
|
|
36127
36136
|
});
|
|
36128
|
-
|
|
36137
|
+
}
|
|
36138
|
+
})();
|
|
36139
|
+
return () => {
|
|
36140
|
+
cancelledRef.current = true;
|
|
36141
|
+
};
|
|
36142
|
+
}, []);
|
|
36143
|
+
const openAndPoll = (0, import_react22.useCallback)(() => {
|
|
36144
|
+
const session = sessionRef.current;
|
|
36145
|
+
if (!session) return;
|
|
36146
|
+
dispatch({ type: "BROWSER_OPENED" });
|
|
36147
|
+
openBrowser(session.verifyUrl);
|
|
36148
|
+
(async () => {
|
|
36149
|
+
try {
|
|
36129
36150
|
for (let i = 0; i < MAX_POLL_ATTEMPTS; i++) {
|
|
36130
|
-
if (
|
|
36151
|
+
if (cancelledRef.current) return;
|
|
36131
36152
|
await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
|
|
36132
|
-
if (
|
|
36153
|
+
if (cancelledRef.current) return;
|
|
36133
36154
|
try {
|
|
36134
36155
|
const result = await pollAuthSession(session.sessionId);
|
|
36135
36156
|
if (result.status === "complete" && result.apiKey) {
|
|
@@ -36152,11 +36173,8 @@ function useLogin() {
|
|
|
36152
36173
|
});
|
|
36153
36174
|
}
|
|
36154
36175
|
})();
|
|
36155
|
-
return () => {
|
|
36156
|
-
cancelled = true;
|
|
36157
|
-
};
|
|
36158
36176
|
}, []);
|
|
36159
|
-
return state;
|
|
36177
|
+
return { state, openAndPoll };
|
|
36160
36178
|
}
|
|
36161
36179
|
var import_react22, POLL_INTERVAL_MS, MAX_POLL_ATTEMPTS;
|
|
36162
36180
|
var init_useLogin = __esm({
|
|
@@ -38804,7 +38822,7 @@ var init_LoginApp = __esm({
|
|
|
38804
38822
|
await init_Spinner();
|
|
38805
38823
|
import_jsx_runtime2 = __toESM(require_jsx_runtime());
|
|
38806
38824
|
LoginApp = () => {
|
|
38807
|
-
const state = useLogin();
|
|
38825
|
+
const { state, openAndPoll } = useLogin();
|
|
38808
38826
|
const { exit } = use_app_default();
|
|
38809
38827
|
(0, import_react24.useEffect)(() => {
|
|
38810
38828
|
if (state.phase === "success") {
|
|
@@ -38823,6 +38841,11 @@ var init_LoginApp = __esm({
|
|
|
38823
38841
|
return () => clearTimeout(timer);
|
|
38824
38842
|
}
|
|
38825
38843
|
}, [state, exit]);
|
|
38844
|
+
use_input_default((_input, key) => {
|
|
38845
|
+
if (state.phase === "ready" && key.return) {
|
|
38846
|
+
openAndPoll();
|
|
38847
|
+
}
|
|
38848
|
+
});
|
|
38826
38849
|
switch (state.phase) {
|
|
38827
38850
|
case "creating":
|
|
38828
38851
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spinner2, { label: "Creating login session..." });
|
|
@@ -38835,12 +38858,19 @@ var init_LoginApp = __esm({
|
|
|
38835
38858
|
" first to re-authenticate."
|
|
38836
38859
|
] })
|
|
38837
38860
|
] });
|
|
38861
|
+
case "ready":
|
|
38862
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", paddingLeft: 1, children: [
|
|
38863
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: " " }),
|
|
38864
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: "Authenticate your account at:" }),
|
|
38865
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: "cyan", children: state.verifyUrl }),
|
|
38866
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: " " }),
|
|
38867
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { dimColor: true, children: "Press ENTER to open in the browser..." })
|
|
38868
|
+
] });
|
|
38838
38869
|
case "waiting":
|
|
38839
38870
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", paddingLeft: 1, children: [
|
|
38840
38871
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: " " }),
|
|
38841
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: "
|
|
38842
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, {
|
|
38843
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { dimColor: true, color: "cyan", children: state.verifyUrl }),
|
|
38872
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: "Authenticate your account at:" }),
|
|
38873
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: "cyan", children: state.verifyUrl }),
|
|
38844
38874
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: " " }),
|
|
38845
38875
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spinner2, { label: "Waiting for authorization..." })
|
|
38846
38876
|
] });
|
|
@@ -39932,11 +39962,22 @@ async function runStaticLogin() {
|
|
|
39932
39962
|
process.exit(1);
|
|
39933
39963
|
}
|
|
39934
39964
|
process.stderr.write(`
|
|
39935
|
-
|
|
39965
|
+
Authenticate your account at:
|
|
39936
39966
|
`);
|
|
39937
|
-
process.stderr.write(`
|
|
39967
|
+
process.stderr.write(` ${import_chalk4.default.cyan(session.verifyUrl)}
|
|
39938
39968
|
|
|
39939
39969
|
`);
|
|
39970
|
+
process.stderr.write(import_chalk4.default.dim(" Press ENTER to open in the browser...\n"));
|
|
39971
|
+
await new Promise((resolve) => {
|
|
39972
|
+
const onData = () => {
|
|
39973
|
+
process.stdin.removeListener("data", onData);
|
|
39974
|
+
if (process.stdin.unref) process.stdin.unref();
|
|
39975
|
+
resolve();
|
|
39976
|
+
};
|
|
39977
|
+
process.stdin.setEncoding("utf-8");
|
|
39978
|
+
process.stdin.resume();
|
|
39979
|
+
process.stdin.on("data", onData);
|
|
39980
|
+
});
|
|
39940
39981
|
try {
|
|
39941
39982
|
openBrowser2(session.verifyUrl);
|
|
39942
39983
|
} catch {
|
|
@@ -40274,9 +40315,9 @@ function useNpmWrapper(npmArgs, config) {
|
|
|
40274
40315
|
return;
|
|
40275
40316
|
}
|
|
40276
40317
|
dispatch({ type: "BLOCKED", result, dgForce: false });
|
|
40277
|
-
const shouldProceed = await new Promise((
|
|
40278
|
-
pendingInstall.current = () =>
|
|
40279
|
-
rejectRef.current = () =>
|
|
40318
|
+
const shouldProceed = await new Promise((resolve) => {
|
|
40319
|
+
pendingInstall.current = () => resolve(true);
|
|
40320
|
+
rejectRef.current = () => resolve(false);
|
|
40280
40321
|
});
|
|
40281
40322
|
if (shouldProceed) {
|
|
40282
40323
|
dispatch({ type: "INSTALLING" });
|