@mohitkumawat/warmup-cli 1.2.15 → 1.3.0
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/README.md +37 -14
- package/dist/commands/default.d.ts +3 -1
- package/dist/commands/default.d.ts.map +1 -1
- package/dist/commands/default.js +25 -0
- package/dist/commands/default.js.map +1 -1
- package/dist/commands/doctor.d.ts +51 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +219 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/execute.d.ts +24 -1
- package/dist/commands/execute.d.ts.map +1 -1
- package/dist/commands/execute.js +53 -21
- package/dist/commands/execute.js.map +1 -1
- package/dist/commands/logs.d.ts +12 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +27 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/menu.d.ts +52 -0
- package/dist/commands/menu.d.ts.map +1 -0
- package/dist/commands/menu.js +185 -0
- package/dist/commands/menu.js.map +1 -0
- package/dist/commands/setup.d.ts +7 -0
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +94 -5
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/status.d.ts +8 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +89 -4
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +25 -4
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/uninstall.d.ts.map +1 -1
- package/dist/commands/uninstall.js +15 -0
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/config.d.ts +23 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +38 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -3
- package/dist/index.js.map +1 -1
- package/dist/notify.d.ts +14 -0
- package/dist/notify.d.ts.map +1 -0
- package/dist/notify.js +91 -0
- package/dist/notify.js.map +1 -0
- package/dist/runtime.d.ts +10 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +39 -8
- package/dist/runtime.js.map +1 -1
- package/dist/scheduler/index.d.ts +17 -0
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +42 -0
- package/dist/scheduler/index.js.map +1 -1
- package/dist/scheduler/linux.d.ts.map +1 -1
- package/dist/scheduler/linux.js +3 -10
- package/dist/scheduler/linux.js.map +1 -1
- package/dist/scheduler/macos.d.ts +38 -0
- package/dist/scheduler/macos.d.ts.map +1 -1
- package/dist/scheduler/macos.js +158 -23
- package/dist/scheduler/macos.js.map +1 -1
- package/dist/scheduler/script.d.ts +18 -0
- package/dist/scheduler/script.d.ts.map +1 -0
- package/dist/scheduler/script.js +62 -0
- package/dist/scheduler/script.js.map +1 -0
- package/dist/scheduler/windows.js +1 -1
- package/dist/ui.d.ts +50 -4
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +250 -38
- package/dist/ui.js.map +1 -1
- package/dist/warmup.d.ts +52 -4
- package/dist/warmup.d.ts.map +1 -1
- package/dist/warmup.js +194 -79
- package/dist/warmup.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBjF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logsCommand = logsCommand;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const ui_1 = require("../ui");
|
|
6
|
+
/**
|
|
7
|
+
* `warmup logs` — show recent pre-warm run history (newest first). Also reused
|
|
8
|
+
* by the interactive hub's "View recent runs". Scriptable: `--json` emits the
|
|
9
|
+
* raw entries (no chrome) for piping; otherwise a pretty list. In a non-TTY
|
|
10
|
+
* context it just prints and exits.
|
|
11
|
+
*/
|
|
12
|
+
async function logsCommand(options = {}) {
|
|
13
|
+
const config = (0, config_1.readConfig)();
|
|
14
|
+
const limit = options.limit && options.limit > 0 ? options.limit : 10;
|
|
15
|
+
if (options.json) {
|
|
16
|
+
const entries = config ? (0, config_1.getRecentLogs)(limit) : [];
|
|
17
|
+
process.stdout.write(`${JSON.stringify(entries, null, 2)}\n`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
(0, ui_1.printMiniLogo)();
|
|
21
|
+
if (!config) {
|
|
22
|
+
(0, ui_1.printNotSetup)();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
(0, ui_1.printRecentRuns)((0, config_1.getRecentLogs)(limit), config.schedule.timezone);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":";;AAcA,kCAgBC;AA9BD,sCAAsD;AACtD,8BAAsE;AAOtE;;;;;GAKG;AACI,KAAK,UAAU,WAAW,CAAC,UAA8B,EAAE;IAChE,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,IAAA,sBAAa,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9D,OAAO;IACT,CAAC;IAED,IAAA,kBAAa,GAAE,CAAC;IAChB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,IAAA,kBAAa,GAAE,CAAC;QAChB,OAAO;IACT,CAAC;IACD,IAAA,oBAAe,EAAC,IAAA,sBAAa,EAAC,KAAK,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { readConfig, type WarmupConfig } from '../config';
|
|
2
|
+
export type MenuAction = 'status' | 'logs' | 'doctor' | 'update' | 'test' | 'toggle' | 'help' | 'uninstall' | 'exit';
|
|
3
|
+
export interface MenuChoice {
|
|
4
|
+
name: string;
|
|
5
|
+
value: MenuAction;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Build the interactive home-menu choices for the current config state.
|
|
9
|
+
* Pure and synchronous so the menu contents can be unit-tested without a TTY.
|
|
10
|
+
* The pause/resume entry flips to match whether the schedule is enabled.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildMenuChoices(config: WarmupConfig): MenuChoice[];
|
|
13
|
+
/**
|
|
14
|
+
* Autocomplete source: substring-filter the menu by what the user types (case-
|
|
15
|
+
* insensitive). Empty input shows everything. Returned as a factory so the
|
|
16
|
+
* choices are captured per frame.
|
|
17
|
+
*/
|
|
18
|
+
export declare function filterMenuChoices(choices: MenuChoice[]): (_answers: unknown, input?: string) => Promise<MenuChoice[]>;
|
|
19
|
+
export interface InteractiveHomeActions {
|
|
20
|
+
status: () => Promise<void>;
|
|
21
|
+
logs: () => Promise<void>;
|
|
22
|
+
doctor: () => Promise<void>;
|
|
23
|
+
update: () => Promise<void>;
|
|
24
|
+
test: () => Promise<void>;
|
|
25
|
+
pause: () => Promise<void>;
|
|
26
|
+
resume: () => Promise<void>;
|
|
27
|
+
help: () => Promise<void>;
|
|
28
|
+
uninstall: () => Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export interface InteractiveHomeDependencies {
|
|
31
|
+
prompt: (questions: unknown) => Promise<Record<string, unknown>>;
|
|
32
|
+
readConfig: typeof readConfig;
|
|
33
|
+
actions: InteractiveHomeActions;
|
|
34
|
+
/** Clear+repaint the frame. No-op in non-TTY (and in tests). */
|
|
35
|
+
clearScreen: () => void;
|
|
36
|
+
/** Pause so the user can read an action's output before the next repaint. */
|
|
37
|
+
waitForKey: () => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Interactive "home" hub shown when a configured user runs bare `warmup` in a
|
|
41
|
+
* terminal. Each frame repaints from a clean screen: the status dashboard
|
|
42
|
+
* (persistent header + live context), a keyboard-hint footer, then an arrow-key
|
|
43
|
+
* menu. Selecting an action runs it, pauses so the output is readable, then
|
|
44
|
+
* returns to a fresh frame — so the whole tool is browsable without retyping
|
|
45
|
+
* subcommands, until the user picks Exit (or confirms Uninstall).
|
|
46
|
+
*
|
|
47
|
+
* The caller gates this on an interactive TTY; non-interactive contexts keep
|
|
48
|
+
* the one-shot status print, so `warmup` stays scriptable and never blocks on a
|
|
49
|
+
* prompt (launchd/systemd/CI/pipes). The cursor is always restored on exit.
|
|
50
|
+
*/
|
|
51
|
+
export declare function runInteractiveHome(deps?: Partial<InteractiveHomeDependencies>): Promise<void>;
|
|
52
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/commands/menu.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAiB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAoBzE,MAAM,MAAM,UAAU,GAClB,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAA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CACjC;AA2BD;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,GAAE,OAAO,CAAC,2BAA2B,CAAM,GAC9C,OAAO,CAAC,IAAI,CAAC,CA+Ff"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildMenuChoices = buildMenuChoices;
|
|
7
|
+
exports.filterMenuChoices = filterMenuChoices;
|
|
8
|
+
exports.runInteractiveHome = runInteractiveHome;
|
|
9
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
10
|
+
const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
|
|
11
|
+
const config_1 = require("../config");
|
|
12
|
+
const ui_1 = require("../ui");
|
|
13
|
+
const status_1 = require("./status");
|
|
14
|
+
const update_1 = require("./update");
|
|
15
|
+
const test_1 = require("./test");
|
|
16
|
+
const pause_1 = require("./pause");
|
|
17
|
+
const resume_1 = require("./resume");
|
|
18
|
+
const uninstall_1 = require("./uninstall");
|
|
19
|
+
const doctor_1 = require("./doctor");
|
|
20
|
+
// Enable the slash-command-style "type to filter" menu (substring match over
|
|
21
|
+
// the visible labels). Registered once; harmless in tests, which inject prompt.
|
|
22
|
+
inquirer_1.default.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
|
|
23
|
+
/**
|
|
24
|
+
* Build the interactive home-menu choices for the current config state.
|
|
25
|
+
* Pure and synchronous so the menu contents can be unit-tested without a TTY.
|
|
26
|
+
* The pause/resume entry flips to match whether the schedule is enabled.
|
|
27
|
+
*/
|
|
28
|
+
function buildMenuChoices(config) {
|
|
29
|
+
const paused = !config.schedule.enabled;
|
|
30
|
+
return [
|
|
31
|
+
{ name: 'View status', value: 'status' },
|
|
32
|
+
{ name: 'View recent runs', value: 'logs' },
|
|
33
|
+
{ name: 'Run health check', value: 'doctor' },
|
|
34
|
+
{ name: 'Change schedule', value: 'update' },
|
|
35
|
+
{ name: 'Run a pre-warm now', value: 'test' },
|
|
36
|
+
paused
|
|
37
|
+
? { name: 'Resume daily schedule', value: 'toggle' }
|
|
38
|
+
: { name: 'Pause daily schedule', value: 'toggle' },
|
|
39
|
+
{ name: 'Help / about', value: 'help' },
|
|
40
|
+
{ name: 'Uninstall warmup', value: 'uninstall' },
|
|
41
|
+
{ name: 'Exit', value: 'exit' },
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Autocomplete source: substring-filter the menu by what the user types (case-
|
|
46
|
+
* insensitive). Empty input shows everything. Returned as a factory so the
|
|
47
|
+
* choices are captured per frame.
|
|
48
|
+
*/
|
|
49
|
+
function filterMenuChoices(choices) {
|
|
50
|
+
return async (_answers, input) => {
|
|
51
|
+
const term = (input || '').trim().toLowerCase();
|
|
52
|
+
if (!term)
|
|
53
|
+
return choices;
|
|
54
|
+
return choices.filter(choice => choice.name.toLowerCase().includes(term));
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const defaultActions = {
|
|
58
|
+
status: status_1.statusCommand,
|
|
59
|
+
logs: async () => {
|
|
60
|
+
const config = (0, config_1.readConfig)();
|
|
61
|
+
(0, ui_1.printRecentRuns)((0, config_1.getRecentLogs)(), config?.schedule.timezone);
|
|
62
|
+
},
|
|
63
|
+
doctor: doctor_1.doctorCommand,
|
|
64
|
+
update: update_1.updateCommand,
|
|
65
|
+
test: () => (0, test_1.testCommand)({}),
|
|
66
|
+
pause: pause_1.pauseCommand,
|
|
67
|
+
resume: resume_1.resumeCommand,
|
|
68
|
+
help: async () => { (0, ui_1.printHubHelp)(); },
|
|
69
|
+
uninstall: uninstall_1.uninstallCommand,
|
|
70
|
+
};
|
|
71
|
+
const inquirerPrompt = inquirer_1.default.prompt;
|
|
72
|
+
const defaultWaitForKey = async () => {
|
|
73
|
+
await inquirerPrompt([{
|
|
74
|
+
type: 'input',
|
|
75
|
+
name: 'continue',
|
|
76
|
+
message: 'Press enter to return to the menu',
|
|
77
|
+
}]);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Interactive "home" hub shown when a configured user runs bare `warmup` in a
|
|
81
|
+
* terminal. Each frame repaints from a clean screen: the status dashboard
|
|
82
|
+
* (persistent header + live context), a keyboard-hint footer, then an arrow-key
|
|
83
|
+
* menu. Selecting an action runs it, pauses so the output is readable, then
|
|
84
|
+
* returns to a fresh frame — so the whole tool is browsable without retyping
|
|
85
|
+
* subcommands, until the user picks Exit (or confirms Uninstall).
|
|
86
|
+
*
|
|
87
|
+
* The caller gates this on an interactive TTY; non-interactive contexts keep
|
|
88
|
+
* the one-shot status print, so `warmup` stays scriptable and never blocks on a
|
|
89
|
+
* prompt (launchd/systemd/CI/pipes). The cursor is always restored on exit.
|
|
90
|
+
*/
|
|
91
|
+
async function runInteractiveHome(deps = {}) {
|
|
92
|
+
const prompt = deps.prompt ?? inquirerPrompt;
|
|
93
|
+
const loadConfig = deps.readConfig ?? config_1.readConfig;
|
|
94
|
+
const actions = deps.actions ?? defaultActions;
|
|
95
|
+
const clear = deps.clearScreen ?? ui_1.clearScreen;
|
|
96
|
+
const waitForKey = deps.waitForKey ?? defaultWaitForKey;
|
|
97
|
+
try {
|
|
98
|
+
for (;;) {
|
|
99
|
+
const config = loadConfig();
|
|
100
|
+
if (!config) {
|
|
101
|
+
// Config went away mid-session (e.g. the user just uninstalled).
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// Repaint a clean frame: the dashboard is the persistent header/context.
|
|
105
|
+
clear();
|
|
106
|
+
await actions.status();
|
|
107
|
+
(0, ui_1.printMenuHint)();
|
|
108
|
+
const { action } = await prompt([{
|
|
109
|
+
type: 'autocomplete',
|
|
110
|
+
name: 'action',
|
|
111
|
+
message: 'What would you like to do?',
|
|
112
|
+
source: filterMenuChoices(buildMenuChoices(config)),
|
|
113
|
+
pageSize: 10,
|
|
114
|
+
}]);
|
|
115
|
+
switch (action) {
|
|
116
|
+
case 'status':
|
|
117
|
+
// The dashboard is already shown at the top of every frame; selecting
|
|
118
|
+
// this simply repaints (next loop iteration), so nothing else to do.
|
|
119
|
+
break;
|
|
120
|
+
case 'logs':
|
|
121
|
+
await actions.logs();
|
|
122
|
+
await waitForKey();
|
|
123
|
+
break;
|
|
124
|
+
case 'doctor':
|
|
125
|
+
await actions.doctor();
|
|
126
|
+
await waitForKey();
|
|
127
|
+
break;
|
|
128
|
+
case 'update':
|
|
129
|
+
await actions.update();
|
|
130
|
+
await waitForKey();
|
|
131
|
+
break;
|
|
132
|
+
case 'test': {
|
|
133
|
+
// Firing here consumes a real 5-hour window — never one keystroke away
|
|
134
|
+
// by accident. Confirm before spending it.
|
|
135
|
+
const { confirmTest } = await prompt([{
|
|
136
|
+
type: 'confirm',
|
|
137
|
+
name: 'confirmTest',
|
|
138
|
+
message: 'Send a real pre-warm now? This starts a fresh 5-hour window.',
|
|
139
|
+
default: false,
|
|
140
|
+
}]);
|
|
141
|
+
if (confirmTest) {
|
|
142
|
+
await actions.test();
|
|
143
|
+
await waitForKey();
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
case 'toggle':
|
|
148
|
+
if (config.schedule.enabled) {
|
|
149
|
+
await actions.pause();
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
await actions.resume();
|
|
153
|
+
}
|
|
154
|
+
await waitForKey();
|
|
155
|
+
break;
|
|
156
|
+
case 'help':
|
|
157
|
+
await actions.help();
|
|
158
|
+
await waitForKey();
|
|
159
|
+
break;
|
|
160
|
+
case 'uninstall': {
|
|
161
|
+
// Destructive — confirm before removing the scheduled task.
|
|
162
|
+
const { confirmUninstall } = await prompt([{
|
|
163
|
+
type: 'confirm',
|
|
164
|
+
name: 'confirmUninstall',
|
|
165
|
+
message: 'Remove the scheduled task? (your config is preserved)',
|
|
166
|
+
default: false,
|
|
167
|
+
}]);
|
|
168
|
+
if (confirmUninstall) {
|
|
169
|
+
await actions.uninstall();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
case 'exit':
|
|
175
|
+
default:
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
// inquirer hides the cursor; make sure it's back on any exit path.
|
|
182
|
+
(0, ui_1.showCursor)();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/commands/menu.ts"],"names":[],"mappings":";;;;;AAmCA,4CAeC;AAOD,8CAMC;AA6DD,gDAiGC;AA7ND,wDAAgC;AAChC,gGAA8D;AAC9D,sCAAyE;AACzE,8BAMe;AACf,qCAAyC;AACzC,qCAAyC;AACzC,iCAAqC;AACrC,mCAAuC;AACvC,qCAAyC;AACzC,2CAA+C;AAC/C,qCAAyC;AAEzC,6EAA6E;AAC7E,gFAAgF;AAChF,kBAAQ,CAAC,cAAc,CAAC,cAAc,EAAE,sCAAkB,CAAC,CAAC;AAU5D;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,MAAoB;IACnD,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;IACxC,OAAO;QACL,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE;QACxC,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,EAAE;QAC3C,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC7C,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC5C,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,MA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AC5D,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,CAAC;4BACzC,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,kBAAkB;4BACxB,OAAO,EAAE,uDAAuD;4BAChE,OAAO,EAAE,KAAK;yBACf,CAAC,CAAkC,CAAC;oBACrC,IAAI,gBAAgB,EAAE,CAAC;wBACrB,MAAM,OAAO,CAAC,SAAS,EAAE,CAAC;wBAC1B,OAAO;oBACT,CAAC;oBACD,MAAM;gBACR,CAAC;gBACD,KAAK,MAAM,CAAC;gBACZ;oBACE,OAAO;YACX,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,mEAAmE;QACnE,IAAA,eAAU,GAAE,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/commands/setup.d.ts
CHANGED
|
@@ -28,7 +28,14 @@ interface ConfirmAndInstallDependencies {
|
|
|
28
28
|
createDefaultConfig: (time: string, timezone: string, runtime: RuntimePaths) => WarmupConfig;
|
|
29
29
|
writeConfig: (config: WarmupConfig) => void;
|
|
30
30
|
animateSetupComplete: (config: WarmupConfig) => Promise<void>;
|
|
31
|
+
configureWakeSchedule: (hour: number, minute: number) => Promise<void>;
|
|
31
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Schedule a system wake so the pre-warm can fire while the Mac is asleep.
|
|
35
|
+
* launchd alone cannot wake the machine, so without this the warmup only runs
|
|
36
|
+
* once the user manually wakes it — too late to actually pre-warm.
|
|
37
|
+
*/
|
|
38
|
+
export declare function configureWakeSchedule(hour: number, minute: number): Promise<void>;
|
|
32
39
|
/** Generate choices for work start time (30 min increments) */
|
|
33
40
|
export declare function generateStartTimeChoices(): Array<{
|
|
34
41
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAGA,OAAO,EAOL,YAAY,EACb,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,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MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkEvF;AAED,+DAA+D;AAC/D,wBAAgB,wBAAwB,IAAI,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAqBjF;AAED,iEAAiE;AACjE,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CA4B7D;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,MAAM,CAAC,CAAM,GACzE,gBAAgB,CAclB;AAoBD,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,gBAAgB,EACtB,IAAI,GAAE,OAAO,CAAC,6BAA6B,CAAM,GAChD,OAAO,CAAC,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC,CA+C/C;AAED,wBAAsB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6EnF"}
|
package/dist/commands/setup.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.configureWakeSchedule = configureWakeSchedule;
|
|
6
7
|
exports.generateStartTimeChoices = generateStartTimeChoices;
|
|
7
8
|
exports.calculateOptimalPrewarm = calculateOptimalPrewarm;
|
|
8
9
|
exports.buildSetupInstallPlan = buildSetupInstallPlan;
|
|
@@ -18,6 +19,78 @@ const ui_1 = require("../ui");
|
|
|
18
19
|
const runtime_1 = require("../runtime");
|
|
19
20
|
const ACCENT = chalk_1.default.hex('#6C5CE7');
|
|
20
21
|
const DIM = chalk_1.default.gray;
|
|
22
|
+
/** Always schedule the pre-warm at least this many minutes before the user's
|
|
23
|
+
* start time, so the rate-limit window is primed before they sit down rather
|
|
24
|
+
* than firing at the moment work begins. */
|
|
25
|
+
const WARM_LEAD_MINUTES = 5;
|
|
26
|
+
/**
|
|
27
|
+
* Schedule a system wake so the pre-warm can fire while the Mac is asleep.
|
|
28
|
+
* launchd alone cannot wake the machine, so without this the warmup only runs
|
|
29
|
+
* once the user manually wakes it — too late to actually pre-warm.
|
|
30
|
+
*/
|
|
31
|
+
async function configureWakeSchedule(hour, minute) {
|
|
32
|
+
const commandHint = (0, scheduler_1.getWakeCommandHint)(hour, minute);
|
|
33
|
+
if (!commandHint) {
|
|
34
|
+
// Non-macOS: waking is part of the scheduled task definition itself.
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const config = (0, config_1.readConfig)();
|
|
38
|
+
console.log('');
|
|
39
|
+
console.log(` ${ACCENT('One more step:')} ${DIM('let warmup wake your Mac so it can pre-warm while you sleep.')}`);
|
|
40
|
+
// macOS has a single global `pmset repeat` slot. Warn before replacing a wake
|
|
41
|
+
// schedule warmup did not create (config.wake records our ownership).
|
|
42
|
+
if ((0, scheduler_1.isWakeScheduleActive)() && !(config && config.wake)) {
|
|
43
|
+
console.log(` ${chalk_1.default.yellow('⚠')} ${DIM('An existing repeating wake schedule was found. macOS allows only one, so warmup will replace it.')}`);
|
|
44
|
+
}
|
|
45
|
+
const { allowWake } = await inquirer_1.default.prompt([{
|
|
46
|
+
type: 'confirm',
|
|
47
|
+
name: 'allowWake',
|
|
48
|
+
message: 'Schedule a daily wake? (asks for your admin password once)',
|
|
49
|
+
default: true,
|
|
50
|
+
}]);
|
|
51
|
+
if (!allowWake) {
|
|
52
|
+
// If warmup previously owned a wake (e.g. on `update`), clear it so it is
|
|
53
|
+
// not left armed at the OLD time, decoupled from the new schedule. Only
|
|
54
|
+
// forget ownership if the clear actually succeeded — otherwise the wake is
|
|
55
|
+
// still armed and we must keep tracking it.
|
|
56
|
+
if (config && config.wake) {
|
|
57
|
+
const cleared = (0, scheduler_1.clearWakeSchedule)({ interactive: true });
|
|
58
|
+
if (cleared && cleared.status === 'applied') {
|
|
59
|
+
delete config.wake;
|
|
60
|
+
(0, config_1.writeConfig)(config);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// The clear failed (e.g. cancelled sudo) — the old wake is STILL armed.
|
|
64
|
+
// Don't claim "only runs while awake"; tell the user how to stop it.
|
|
65
|
+
console.log(` ${chalk_1.default.yellow('⚠')} ${DIM('A previously scheduled wake is still active and could not be removed. Run this once:')}`);
|
|
66
|
+
console.log(` ${ACCENT('sudo pmset repeat cancel')}`);
|
|
67
|
+
console.log('');
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
console.log(` ${DIM('Skipped — warmup will only run while your Mac is awake. Enable it later with:')}`);
|
|
72
|
+
console.log(` ${ACCENT(commandHint)}`);
|
|
73
|
+
console.log('');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const result = (0, scheduler_1.applyWakeSchedule)(hour, minute, { interactive: true });
|
|
77
|
+
if (result && result.status === 'applied') {
|
|
78
|
+
if (config) {
|
|
79
|
+
const time = (0, scheduler_1.getWakeTime)(hour, minute);
|
|
80
|
+
if (time) {
|
|
81
|
+
config.wake = { time };
|
|
82
|
+
(0, config_1.writeConfig)(config);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
console.log(` ${chalk_1.default.green('✓')} ${DIM('Daily wake scheduled — warmup runs even while your Mac is asleep.')}`);
|
|
86
|
+
console.log(` ${DIM('(Most reliable on AC power. Undo anytime with')} ${ACCENT('sudo pmset repeat cancel')}${DIM('.)')}`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
console.log(` ${chalk_1.default.yellow('⚠')} ${DIM('Could not schedule the wake automatically. Run this once:')}`);
|
|
90
|
+
console.log(` ${ACCENT(commandHint)}`);
|
|
91
|
+
}
|
|
92
|
+
console.log('');
|
|
93
|
+
}
|
|
21
94
|
/** Generate choices for work start time (30 min increments) */
|
|
22
95
|
function generateStartTimeChoices() {
|
|
23
96
|
const choices = [];
|
|
@@ -44,8 +117,13 @@ function generateStartTimeChoices() {
|
|
|
44
117
|
/** Calculate the optimal pre-warm time based on user feedback */
|
|
45
118
|
function calculateOptimalPrewarm(startMins, exhaustMins) {
|
|
46
119
|
let prewarmMins = startMins + exhaustMins - (5 * 60);
|
|
47
|
-
|
|
48
|
-
|
|
120
|
+
// Never schedule at or after the start time — the pre-warm must complete
|
|
121
|
+
// *before* the user begins, leaving a small lead. (Previously this clamped to
|
|
122
|
+
// exactly startMins, so a "5+ hours" answer scheduled the warmup for the very
|
|
123
|
+
// minute work began, defeating the point of pre-warming.)
|
|
124
|
+
const latestPrewarm = startMins - WARM_LEAD_MINUTES;
|
|
125
|
+
if (prewarmMins > latestPrewarm) {
|
|
126
|
+
prewarmMins = latestPrewarm;
|
|
49
127
|
}
|
|
50
128
|
if (prewarmMins < 0) {
|
|
51
129
|
prewarmMins += 24 * 60;
|
|
@@ -100,26 +178,37 @@ async function confirmAndInstallSchedule(plan, deps = {}) {
|
|
|
100
178
|
const makeConfig = deps.createDefaultConfig ?? config_1.createDefaultConfig;
|
|
101
179
|
const persistConfig = deps.writeConfig ?? config_1.writeConfig;
|
|
102
180
|
const finishSetup = deps.animateSetupComplete ?? ui_1.animateSetupComplete;
|
|
181
|
+
const setupWake = deps.configureWakeSchedule ?? configureWakeSchedule;
|
|
103
182
|
showInstallPreview(plan);
|
|
104
183
|
if (!(await confirmInstall())) {
|
|
105
184
|
showSetupDeferred();
|
|
106
185
|
return 'cancelled';
|
|
107
186
|
}
|
|
108
187
|
const installSpinner = startInstallSpinner(plan.schedulerLabel);
|
|
188
|
+
let config;
|
|
109
189
|
try {
|
|
110
190
|
ensureDir();
|
|
111
191
|
const runtime = resolveRuntime();
|
|
112
192
|
install({ hour: plan.hour, minute: plan.minute, runtime });
|
|
113
|
-
|
|
193
|
+
config = makeConfig(plan.time, plan.timezone, runtime);
|
|
114
194
|
persistConfig(config);
|
|
115
195
|
installSpinner.succeed('Schedule installed with boot-recovery');
|
|
116
|
-
await finishSetup(config);
|
|
117
|
-
return 'installed';
|
|
118
196
|
}
|
|
119
197
|
catch (err) {
|
|
120
198
|
installSpinner.fail(`Installation failed: ${err.message}`);
|
|
121
199
|
return 'failed';
|
|
122
200
|
}
|
|
201
|
+
// The wake step + completion run AFTER the schedule is installed. A failure
|
|
202
|
+
// here (Ctrl-C at the wake prompt, non-TTY stdin) must NOT report the install
|
|
203
|
+
// as failed — the schedule and config are already in place.
|
|
204
|
+
try {
|
|
205
|
+
await setupWake(plan.hour, plan.minute);
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
// wake is best-effort; the schedule is already installed
|
|
209
|
+
}
|
|
210
|
+
await finishSetup(config);
|
|
211
|
+
return 'installed';
|
|
123
212
|
}
|
|
124
213
|
async function setupCommand(options = {}) {
|
|
125
214
|
if (!options.skipLogo) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":";;;;;AA4EA,sDAkEC;AAGD,4DAqBC;AAGD,0D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,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { type WarmupConfig } from '../config';
|
|
2
|
+
export interface StatusCommandOptions {
|
|
3
|
+
watch?: boolean;
|
|
4
|
+
json?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Structured, scriptable view of the current state (`status --json`). */
|
|
7
|
+
export declare function buildStatusReport(config: WarmupConfig): Record<string, unknown>;
|
|
8
|
+
export declare function statusCommand(options?: StatusCommandOptions): Promise<void>;
|
|
2
9
|
//# sourceMappingURL=status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC;AAWnB,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAWD,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqB/E;AAED,wBAAsB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAerF"}
|
package/dist/commands/status.js
CHANGED
|
@@ -1,14 +1,99 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildStatusReport = buildStatusReport;
|
|
3
4
|
exports.statusCommand = statusCommand;
|
|
4
5
|
const config_1 = require("../config");
|
|
5
6
|
const ui_1 = require("../ui");
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const scheduler_1 = require("../scheduler");
|
|
8
|
+
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
9
|
+
/** Whether warmup owns a live macOS wake (undefined on other platforms). */
|
|
10
|
+
function wakeState(config) {
|
|
11
|
+
return (0, scheduler_1.detectPlatform)() === 'macos'
|
|
12
|
+
? Boolean(config.wake) && (0, scheduler_1.isWakeScheduleActive)()
|
|
13
|
+
: undefined;
|
|
14
|
+
}
|
|
15
|
+
/** Structured, scriptable view of the current state (`status --json`). */
|
|
16
|
+
function buildStatusReport(config) {
|
|
17
|
+
const lastLog = (0, config_1.getLatestLog)();
|
|
18
|
+
const warmed = lastLog && (lastLog.status === 'success' || lastLog.status === 'boot-recovery')
|
|
19
|
+
? new Date(lastLog.timestamp)
|
|
20
|
+
: null;
|
|
21
|
+
return {
|
|
22
|
+
version: require('../../package.json').version,
|
|
23
|
+
schedule: {
|
|
24
|
+
time: config.schedule.time,
|
|
25
|
+
timezone: config.schedule.timezone,
|
|
26
|
+
enabled: config.schedule.enabled,
|
|
27
|
+
},
|
|
28
|
+
nextFireAt: (0, config_1.getNextFireTime)(config).toISOString(),
|
|
29
|
+
window: warmed
|
|
30
|
+
? { active: true, resetAt: (0, config_1.getWindowResetTime)(warmed).toISOString(), progress: (0, config_1.getWindowProgress)(warmed) }
|
|
31
|
+
: { active: false, resetAt: null, progress: null },
|
|
32
|
+
lastRun: lastLog
|
|
33
|
+
? { status: lastLog.status, timestamp: lastLog.timestamp, actualTime: lastLog.actualTime ?? null, message: lastLog.message }
|
|
34
|
+
: null,
|
|
35
|
+
wakeScheduled: wakeState(config) ?? null,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async function statusCommand(options = {}) {
|
|
39
|
+
if (options.json) {
|
|
40
|
+
const config = (0, config_1.readConfig)();
|
|
41
|
+
process.stdout.write(`${JSON.stringify(config ? buildStatusReport(config) : { configured: false }, null, 2)}\n`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Live mode only in a real terminal; piped/CI gets the one-shot print so it
|
|
45
|
+
// stays scriptable and never spins forever.
|
|
46
|
+
if (options.watch && process.stdout.isTTY) {
|
|
47
|
+
await runStatusWatch();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await renderStatusOnce();
|
|
51
|
+
}
|
|
52
|
+
async function renderStatusOnce(existingConfig) {
|
|
53
|
+
const config = existingConfig ?? (0, config_1.readConfig)();
|
|
8
54
|
if (!config) {
|
|
9
55
|
(0, ui_1.printNotSetup)();
|
|
10
|
-
return;
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
// Only macOS exposes a separately-managed wake (wakeState returns undefined
|
|
59
|
+
// elsewhere, so the row is omitted); report "scheduled" only when warmup owns
|
|
60
|
+
// the live wake — a foreign pmset repeat must not be attributed to warmup.
|
|
61
|
+
await (0, ui_1.displayStatus)(config, {
|
|
62
|
+
needsRuntimeRefresh: !config.runtime,
|
|
63
|
+
wakeScheduleActive: wakeState(config),
|
|
64
|
+
});
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `warmup status --watch`: repaint the dashboard every second so the rate-limit
|
|
69
|
+
* window bar and the "next in …" countdown stay live. TTY-only. Ctrl+C restores
|
|
70
|
+
* the cursor (hidden during the ticker) and exits cleanly. Bails immediately if
|
|
71
|
+
* warmup isn't set up rather than looping on the not-set-up screen.
|
|
72
|
+
*/
|
|
73
|
+
async function runStatusWatch() {
|
|
74
|
+
const onSigint = () => {
|
|
75
|
+
(0, ui_1.showCursor)();
|
|
76
|
+
process.exit(0);
|
|
77
|
+
};
|
|
78
|
+
process.on('SIGINT', onSigint);
|
|
79
|
+
process.stdout.write('\x1b[?25l'); // hide cursor for a stable ticker
|
|
80
|
+
try {
|
|
81
|
+
for (;;) {
|
|
82
|
+
const config = (0, config_1.readConfig)();
|
|
83
|
+
(0, ui_1.repaintFrame)();
|
|
84
|
+
if (!config) {
|
|
85
|
+
(0, ui_1.printNotSetup)();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
console.log((0, ui_1.renderStatusLine)(config));
|
|
89
|
+
await renderStatusOnce(config); // reuse the config we just read (one read/frame)
|
|
90
|
+
(0, ui_1.printWatchFooter)();
|
|
91
|
+
await sleep(1000);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
(0, ui_1.showCursor)();
|
|
96
|
+
process.removeListener('SIGINT', onSigint);
|
|
11
97
|
}
|
|
12
|
-
await (0, ui_1.displayStatus)(config, { needsRuntimeRefresh: !config.runtime });
|
|
13
98
|
}
|
|
14
99
|
//# sourceMappingURL=status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":";;AAiCA,8CAqBC;AAED,sCAeC;AAvED,sCAOmB;AACnB,8BAOe;AACf,4CAAoE;AAOpE,MAAM,KAAK,GAAG,CAAC,EAAU,EAAiB,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAE7F,4EAA4E;AAC5E,SAAS,SAAS,CAAC,MAAoB;IACrC,OAAO,IAAA,0BAAc,GAAE,KAAK,OAAO;QACjC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAA,gCAAoB,GAAE;QAChD,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,0EAA0E;AAC1E,SAAgB,iBAAiB,CAAC,MAAoB;IACpD,MAAM,OAAO,GAAG,IAAA,qBAAY,GAAE,CAAC;IAC/B,MAAM,MAAM,GAAG,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,eAAe,CAAC;QAC5F,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QA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T,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,IAAA,qBAAgB,EAAC,MAAM,CAAC,CAAC,CAAC;YACtC,MAAM,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,iDAAiD;YACjF,IAAA,qBAAgB,GAAE,CAAC;YACnB,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;YAAS,CAAC;QACT,IAAA,eAAU,GAAE,CAAC;QACb,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwCjF"}
|