@episoda/cli 0.2.178 → 0.2.179
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/daemon/daemon-process.js +100 -3
- package/dist/daemon/daemon-process.js.map +1 -1
- package/dist/index.js +56 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5417,6 +5417,28 @@ main "$@"
|
|
|
5417
5417
|
var CREDENTIAL_HELPER_SCRIPT = generateCredentialHelperScript("https://episoda.dev");
|
|
5418
5418
|
|
|
5419
5419
|
// src/commands/auth.ts
|
|
5420
|
+
async function logoutCommand() {
|
|
5421
|
+
const configPath = (0, import_core6.getConfigPath)();
|
|
5422
|
+
if (!fs7.existsSync(configPath)) {
|
|
5423
|
+
status.info("No local auth session found.");
|
|
5424
|
+
return;
|
|
5425
|
+
}
|
|
5426
|
+
let config = {};
|
|
5427
|
+
try {
|
|
5428
|
+
config = JSON.parse(fs7.readFileSync(configPath, "utf8"));
|
|
5429
|
+
} catch {
|
|
5430
|
+
fs7.unlinkSync(configPath);
|
|
5431
|
+
status.success("Logged out (removed unreadable local config).");
|
|
5432
|
+
return;
|
|
5433
|
+
}
|
|
5434
|
+
delete config.access_token;
|
|
5435
|
+
delete config.refresh_token;
|
|
5436
|
+
delete config.expires_at;
|
|
5437
|
+
delete config.user_id;
|
|
5438
|
+
fs7.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}
|
|
5439
|
+
`, { mode: 384 });
|
|
5440
|
+
status.success("Logged out successfully.");
|
|
5441
|
+
}
|
|
5420
5442
|
async function authCommand(options = {}) {
|
|
5421
5443
|
const apiUrl = options.apiUrl || process.env.EPISODA_API_URL || "https://episoda.dev";
|
|
5422
5444
|
status.info("Initializing Episoda CLI...");
|
|
@@ -6585,11 +6607,32 @@ async function setupWorktreeEnv(worktreePath, apiUrl, accessToken) {
|
|
|
6585
6607
|
|
|
6586
6608
|
// src/commands/checkout.ts
|
|
6587
6609
|
function generateBranchName(moduleUid, title) {
|
|
6610
|
+
const MAX_BRANCH_NAME_LENGTH = 63;
|
|
6611
|
+
const trimSlugToBudget = (slug2, budget) => {
|
|
6612
|
+
if (budget <= 0) return "";
|
|
6613
|
+
if (slug2.length <= budget) return slug2;
|
|
6614
|
+
const candidate = slug2.slice(0, budget);
|
|
6615
|
+
const lastHyphen = candidate.lastIndexOf("-");
|
|
6616
|
+
if (lastHyphen > 0) {
|
|
6617
|
+
return candidate.slice(0, lastHyphen).replace(/-+$/g, "");
|
|
6618
|
+
}
|
|
6619
|
+
return candidate.replace(/-+$/g, "");
|
|
6620
|
+
};
|
|
6588
6621
|
if (!title) {
|
|
6589
|
-
|
|
6622
|
+
const fallback = moduleUid || "unnamed";
|
|
6623
|
+
return fallback.slice(0, MAX_BRANCH_NAME_LENGTH).replace(/-+$/g, "");
|
|
6590
6624
|
}
|
|
6591
|
-
const slug = title.toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "")
|
|
6592
|
-
|
|
6625
|
+
const slug = title.toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
6626
|
+
if (!moduleUid) {
|
|
6627
|
+
return trimSlugToBudget(slug, MAX_BRANCH_NAME_LENGTH) || "unnamed";
|
|
6628
|
+
}
|
|
6629
|
+
const prefix = `${moduleUid}-`;
|
|
6630
|
+
const slugBudget = MAX_BRANCH_NAME_LENGTH - prefix.length;
|
|
6631
|
+
const trimmedSlug = trimSlugToBudget(slug, slugBudget);
|
|
6632
|
+
if (!trimmedSlug) {
|
|
6633
|
+
return moduleUid.slice(0, MAX_BRANCH_NAME_LENGTH).replace(/-+$/g, "");
|
|
6634
|
+
}
|
|
6635
|
+
return `${moduleUid}-${trimmedSlug}`;
|
|
6593
6636
|
}
|
|
6594
6637
|
async function checkoutCommand(moduleUid, options = {}) {
|
|
6595
6638
|
if (!moduleUid || !moduleUid.match(/^EP\d+$/)) {
|
|
@@ -8077,7 +8120,16 @@ if (protocolArg) {
|
|
|
8077
8120
|
});
|
|
8078
8121
|
}
|
|
8079
8122
|
import_commander.program.name("episoda").description("Episoda CLI - local development with git worktree isolation").version(import_core19.VERSION);
|
|
8080
|
-
import_commander.program.command("auth").description("Authenticate to Episoda via OAuth and configure CLI")
|
|
8123
|
+
var authProgram = import_commander.program.command("auth").description("Authenticate to Episoda via OAuth and configure CLI");
|
|
8124
|
+
authProgram.command("logout").description("Clear local session/token without re-authenticating").action(async () => {
|
|
8125
|
+
try {
|
|
8126
|
+
await logoutCommand();
|
|
8127
|
+
} catch (error) {
|
|
8128
|
+
status.error(`Logout failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
8129
|
+
process.exit(1);
|
|
8130
|
+
}
|
|
8131
|
+
});
|
|
8132
|
+
authProgram.option("--api-url <url>", "API URL (default: https://episoda.dev)").action(async (options) => {
|
|
8081
8133
|
try {
|
|
8082
8134
|
await authCommand(options);
|
|
8083
8135
|
} catch (error) {
|