@eunjae/il 1.1.0 → 1.2.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/dist/scripts/il.mjs +60 -21
- package/package.json +1 -1
package/dist/scripts/il.mjs
CHANGED
|
@@ -687,18 +687,6 @@ const appendDayAssignment = (task, date, action, msg) => {
|
|
|
687
687
|
};
|
|
688
688
|
};
|
|
689
689
|
|
|
690
|
-
//#endregion
|
|
691
|
-
//#region lib/taskStore.ts
|
|
692
|
-
const createTaskInStore = async (workspaceRoot, task) => {
|
|
693
|
-
const { alias, aliases } = await allocateAlias(workspaceRoot, task.type === "pr_review" ? "R" : "T", task.id);
|
|
694
|
-
await writeAliases(workspaceRoot, aliases);
|
|
695
|
-
await saveTask(workspaceRoot, task.status, task);
|
|
696
|
-
return {
|
|
697
|
-
alias,
|
|
698
|
-
task
|
|
699
|
-
};
|
|
700
|
-
};
|
|
701
|
-
|
|
702
690
|
//#endregion
|
|
703
691
|
//#region lib/taskResolver.ts
|
|
704
692
|
const stableRefPattern = /^[TR]-[A-Z0-9]{6}$/;
|
|
@@ -723,6 +711,18 @@ const resolveTask = async (workspaceRoot, identifier) => {
|
|
|
723
711
|
};
|
|
724
712
|
};
|
|
725
713
|
|
|
714
|
+
//#endregion
|
|
715
|
+
//#region lib/taskStore.ts
|
|
716
|
+
const createTaskInStore = async (workspaceRoot, task) => {
|
|
717
|
+
const { alias, aliases } = await allocateAlias(workspaceRoot, task.type === "pr_review" ? "R" : "T", task.id);
|
|
718
|
+
await writeAliases(workspaceRoot, aliases);
|
|
719
|
+
await saveTask(workspaceRoot, task.status, task);
|
|
720
|
+
return {
|
|
721
|
+
alias,
|
|
722
|
+
task
|
|
723
|
+
};
|
|
724
|
+
};
|
|
725
|
+
|
|
726
726
|
//#endregion
|
|
727
727
|
//#region scripts/il.ts
|
|
728
728
|
const program = new Command();
|
|
@@ -752,6 +752,11 @@ const printLines = (lines) => {
|
|
|
752
752
|
}
|
|
753
753
|
process.stdout.write(`${lines.join("\n")}\n`);
|
|
754
754
|
};
|
|
755
|
+
const failWithHelp = (command, message) => {
|
|
756
|
+
process.stderr.write(`${message}\n`);
|
|
757
|
+
command.outputHelp();
|
|
758
|
+
process.exitCode = 1;
|
|
759
|
+
};
|
|
755
760
|
const listScopes = [
|
|
756
761
|
"today",
|
|
757
762
|
"yesterday",
|
|
@@ -787,6 +792,7 @@ const resolvePackageVersion = async () => {
|
|
|
787
792
|
const packageVersion = await resolvePackageVersion();
|
|
788
793
|
program.name("il").description("Terminal task manager").option("--store <path>", "explicit workspace path").option("--global", "use global workspace").option("--repo", "use repo workspace");
|
|
789
794
|
if (packageVersion) program.version(packageVersion);
|
|
795
|
+
program.showHelpAfterError();
|
|
790
796
|
program.command("init").description("initialize repo workspace").action(handleAction(async () => {
|
|
791
797
|
const repoRoot = await findGitRoot(process.cwd());
|
|
792
798
|
if (!repoRoot) throw new Error("Not inside a git repository");
|
|
@@ -806,22 +812,34 @@ program.command("where").description("show resolved workspace").action(handleAct
|
|
|
806
812
|
}));
|
|
807
813
|
program.command("add").description("add a task").argument("[title]", "task title").option("--type <type>", "regular|pr_review", "regular").option("--url <url>", "attach URL").option("--pr <url>", "attach PR URL").action(handleAction(async (title, options, command) => {
|
|
808
814
|
const taskType = options.type;
|
|
809
|
-
if (!taskTypes.includes(taskType))
|
|
810
|
-
|
|
815
|
+
if (!taskTypes.includes(taskType)) {
|
|
816
|
+
failWithHelp(command, `Invalid type: ${taskType}`);
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
if (taskType === "pr_review" && !options.pr) {
|
|
820
|
+
failWithHelp(command, "PR review tasks require --pr");
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
811
823
|
const workspaceRoot = await resolveWorkspaceFor(true);
|
|
812
824
|
await withWorkspaceLock(workspaceRoot, async () => {
|
|
813
825
|
let prAttachment;
|
|
814
826
|
let prTitle;
|
|
815
827
|
if (options.pr) {
|
|
816
828
|
const parsed = parseGitHubPrUrl(options.pr);
|
|
817
|
-
if (!parsed)
|
|
829
|
+
if (!parsed) {
|
|
830
|
+
failWithHelp(command, "Invalid PR URL");
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
818
833
|
const fetched = await fetchGitHubPr(parsed, await resolveGithubToken(workspaceRoot));
|
|
819
834
|
prAttachment = buildPrAttachment(parsed, fetched ?? void 0);
|
|
820
835
|
prTitle = fetched?.title ?? `PR #${parsed.number} ${parsed.repo.owner}/${parsed.repo.name}`;
|
|
821
836
|
}
|
|
822
837
|
const isExplicitTitle = Boolean(title);
|
|
823
838
|
let finalTitle = title ?? prTitle;
|
|
824
|
-
if (!finalTitle)
|
|
839
|
+
if (!finalTitle) {
|
|
840
|
+
failWithHelp(command, "Title is required when no PR URL is provided");
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
825
843
|
if (taskType === "pr_review" && !isExplicitTitle) finalTitle = `Review: ${finalTitle}`;
|
|
826
844
|
const metadata = {
|
|
827
845
|
url: options.url,
|
|
@@ -841,7 +859,10 @@ program.command("list").description("list tasks").argument("[status]", "task sta
|
|
|
841
859
|
const workspaceRoot = await resolveWorkspaceFor(true);
|
|
842
860
|
const aliasLookup = buildAliasLookup(await readAliases(workspaceRoot));
|
|
843
861
|
const lines = [];
|
|
844
|
-
if (status && !isTaskStatus(status) && !isListScope(status))
|
|
862
|
+
if (status && !isTaskStatus(status) && !isListScope(status)) {
|
|
863
|
+
failWithHelp(command, `Invalid status or scope: ${status}`);
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
845
866
|
if (status && isListScope(status)) {
|
|
846
867
|
const dates = listDatesForScope(status);
|
|
847
868
|
const tasks = await listAllTasks(workspaceRoot);
|
|
@@ -892,7 +913,10 @@ addTransitionCommand("cancel");
|
|
|
892
913
|
program.command("log").description("append a log entry").argument("<id>", "task identifier").argument("<message>", "log message").option("--status <status>", "include status in log entry").action(handleAction(async (identifier, message, options, command) => {
|
|
893
914
|
const workspaceRoot = await resolveWorkspaceFor(true);
|
|
894
915
|
const status = options.status;
|
|
895
|
-
if (status && !taskStatuses.includes(status))
|
|
916
|
+
if (status && !taskStatuses.includes(status)) {
|
|
917
|
+
failWithHelp(command, `Invalid status: ${status}`);
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
896
920
|
await withWorkspaceLock(workspaceRoot, async () => {
|
|
897
921
|
const stored = await resolveTask(workspaceRoot, identifier);
|
|
898
922
|
const updated = appendLog(stored.task, message, status);
|
|
@@ -921,7 +945,13 @@ program.command("search").description("search tasks").argument("<query>", "searc
|
|
|
921
945
|
}));
|
|
922
946
|
program.command("today").description("assign a task for today").argument("<id>", "task identifier").option("--date <date>", "YYYY-MM-DD").option("-m, --message <message>", "assignment message").action(handleAction(async (identifier, options, command) => {
|
|
923
947
|
const workspaceRoot = await resolveWorkspaceFor(true);
|
|
924
|
-
|
|
948
|
+
let date;
|
|
949
|
+
try {
|
|
950
|
+
date = todayDate(options.date);
|
|
951
|
+
} catch (error) {
|
|
952
|
+
failWithHelp(command, error instanceof Error ? error.message : String(error));
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
925
955
|
await withWorkspaceLock(workspaceRoot, async () => {
|
|
926
956
|
const stored = await resolveTask(workspaceRoot, identifier);
|
|
927
957
|
if (isAssignedOnDate(stored.task, date)) {
|
|
@@ -935,7 +965,13 @@ program.command("today").description("assign a task for today").argument("<id>",
|
|
|
935
965
|
}));
|
|
936
966
|
program.command("untoday").description("unassign a task from today").argument("<id>", "task identifier").option("--date <date>", "YYYY-MM-DD").action(handleAction(async (identifier, options, command) => {
|
|
937
967
|
const workspaceRoot = await resolveWorkspaceFor(true);
|
|
938
|
-
|
|
968
|
+
let date;
|
|
969
|
+
try {
|
|
970
|
+
date = todayDate(options.date);
|
|
971
|
+
} catch (error) {
|
|
972
|
+
failWithHelp(command, error instanceof Error ? error.message : String(error));
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
939
975
|
await withWorkspaceLock(workspaceRoot, async () => {
|
|
940
976
|
const stored = await resolveTask(workspaceRoot, identifier);
|
|
941
977
|
if (!isAssignedOnDate(stored.task, date)) {
|
|
@@ -951,7 +987,10 @@ program.command("attach-pr").description("attach PR metadata to a task").argumen
|
|
|
951
987
|
const workspaceRoot = await resolveWorkspaceFor(true);
|
|
952
988
|
await withWorkspaceLock(workspaceRoot, async () => {
|
|
953
989
|
const parsed = parseGitHubPrUrl(url);
|
|
954
|
-
if (!parsed)
|
|
990
|
+
if (!parsed) {
|
|
991
|
+
failWithHelp(command, "Invalid PR URL");
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
955
994
|
const fetched = await fetchGitHubPr(parsed, await resolveGithubToken(workspaceRoot));
|
|
956
995
|
const stored = await resolveTask(workspaceRoot, identifier);
|
|
957
996
|
const next = appendLog({
|