@kodly.dev/kodly-cli 1.0.18 → 2.0.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.
Files changed (52) hide show
  1. package/README.md +131 -39
  2. package/dist/bin/kodly.js +23 -38
  3. package/dist/commands/auth.js +73 -78
  4. package/dist/commands/code.js +238 -0
  5. package/dist/commands/completion.js +33 -76
  6. package/dist/commands/delivery.js +218 -0
  7. package/dist/commands/harness.js +68 -0
  8. package/dist/commands/local-qa.js +96 -0
  9. package/dist/commands/mcp.js +399 -0
  10. package/dist/commands/misc.js +58 -0
  11. package/dist/commands/org.js +43 -100
  12. package/dist/commands/plan.js +157 -0
  13. package/dist/commands/project.js +88 -86
  14. package/dist/commands/review.js +237 -0
  15. package/dist/commands/scaffold.js +20 -230
  16. package/dist/commands/story-write.js +210 -0
  17. package/dist/commands/story.js +154 -0
  18. package/dist/core/api.js +89 -0
  19. package/dist/core/browser.js +17 -0
  20. package/dist/core/checkout.js +58 -0
  21. package/dist/core/config.js +36 -0
  22. package/dist/core/confirm.js +36 -0
  23. package/dist/core/context.js +64 -0
  24. package/dist/core/credentials.js +62 -0
  25. package/dist/core/device-login.js +44 -0
  26. package/dist/core/errors.js +32 -0
  27. package/dist/core/format.js +32 -0
  28. package/dist/core/git.js +29 -0
  29. package/dist/core/keychain.js +9 -0
  30. package/dist/core/memberships.js +10 -0
  31. package/dist/core/output.js +31 -0
  32. package/dist/core/prompt.js +47 -0
  33. package/dist/core/push-checks.js +60 -0
  34. package/dist/core/story-file.js +120 -0
  35. package/dist/core/story.js +34 -0
  36. package/dist/program.js +48 -0
  37. package/dist/utils/update-check.js +9 -9
  38. package/llm.txt +47 -83
  39. package/package.json +21 -11
  40. package/dist/api/client.js +0 -96
  41. package/dist/commands/docs.js +0 -152
  42. package/dist/commands/man.js +0 -93
  43. package/dist/commands/push.js +0 -51
  44. package/dist/commands/status.js +0 -52
  45. package/dist/commands/task.js +0 -155
  46. package/dist/utils/changes.js +0 -90
  47. package/dist/utils/checkout.js +0 -168
  48. package/dist/utils/config.js +0 -34
  49. package/dist/utils/org.js +0 -138
  50. package/dist/utils/project.js +0 -21
  51. package/dist/utils/session.js +0 -28
  52. package/dist/utils/task.js +0 -25
@@ -1,51 +0,0 @@
1
- import chalk from 'chalk';
2
- import ora from 'ora';
3
- import { Api } from '../api/client.js';
4
- import { requireAuthAndOrg } from '../utils/session.js';
5
- import { printActiveOrg } from '../utils/org.js';
6
- export const pushCommands = (program) => {
7
- program
8
- .command('push')
9
- .description('Push local changes to Kodly')
10
- .action(async () => {
11
- const org = await requireAuthAndOrg();
12
- if (!org)
13
- return;
14
- const cwd = process.cwd();
15
- const { getTaskData } = await import('../utils/task.js');
16
- const taskData = getTaskData(cwd);
17
- const slug = taskData?.slug || '';
18
- if (!slug) {
19
- console.log(chalk.red('Error: Could not determine task slug. Validation failed, no valid task-*.json found in .kodly directory.'));
20
- return;
21
- }
22
- const spinner = ora(`Scanning files in ${slug}...`).start();
23
- try {
24
- const { getChangedFiles, updateChecksums } = await import('../utils/changes.js');
25
- const { filesToPush, newChecksums } = await getChangedFiles(cwd);
26
- if (filesToPush.length === 0) {
27
- spinner.succeed(chalk.green('No changes detected. Everything is up to date!'));
28
- return;
29
- }
30
- spinner.text = `Pushing ${filesToPush.length} changed files to ${slug}...`;
31
- printActiveOrg(org);
32
- // Map to API DTO { filepath, content, base64Encoded, status }
33
- const payload = filesToPush.map(f => ({
34
- filepath: f.filepath,
35
- content: f.content,
36
- base64Encoded: f.base64Encoded,
37
- status: f.status === 'TO_BE_DELETED' ? 'TO_BE_DELETED' : null
38
- }));
39
- await Api.tasks.push(slug, payload);
40
- updateChecksums(cwd, newChecksums);
41
- spinner.succeed(chalk.green('Successfully pushed changes to cloud!'));
42
- }
43
- catch (error) {
44
- if (error.response) {
45
- console.error('API Error Status:', error.response.status);
46
- console.error('API Error Data:', JSON.stringify(error.response.data, null, 2));
47
- }
48
- spinner.fail(chalk.red('Push failed: ' + (error.message || 'Unknown error')));
49
- }
50
- });
51
- };
@@ -1,52 +0,0 @@
1
- import chalk from 'chalk';
2
- import ora from 'ora';
3
- import { requireAuthAndOrg } from '../utils/session.js';
4
- import { printActiveOrg } from '../utils/org.js';
5
- export const statusCommands = (program) => {
6
- program
7
- .command('status')
8
- .description('Show the working tree status')
9
- .action(async () => {
10
- const org = await requireAuthAndOrg();
11
- if (!org)
12
- return;
13
- const cwd = process.cwd();
14
- const { getTaskData } = await import('../utils/task.js');
15
- const taskData = getTaskData(cwd);
16
- const slug = taskData?.slug || '';
17
- const title = taskData?.title || '';
18
- // Basic validation
19
- if (!slug) {
20
- console.log(chalk.red('Error: Could not determine task slug. Validation failed, no valid task-*.json found in .kodly directory. Are you in a task directory?'));
21
- return;
22
- }
23
- const spinner = ora('Checking status...').start();
24
- try {
25
- const { getChangedFiles } = await import('../utils/changes.js');
26
- const { filesToPush } = await getChangedFiles(cwd);
27
- spinner.stop();
28
- printActiveOrg(org);
29
- console.log(chalk.bold(`On task: ${chalk.cyan(slug)} ${title ? '- ' + title : ''}\n`));
30
- if (filesToPush.length === 0) {
31
- console.log(chalk.green('nothing to commit, working tree clean'));
32
- }
33
- else {
34
- console.log('Changes not pushed to cloud:');
35
- console.log(` (use "kodly push" to update cloud)\n`);
36
- filesToPush.forEach(file => {
37
- let color = chalk.yellow;
38
- if (file.status === 'NEW')
39
- color = chalk.green;
40
- if (file.status === 'TO_BE_DELETED')
41
- color = chalk.red;
42
- // file.filepath includes base path
43
- console.log(`\t${color(file.status.toLowerCase() + ': ' + file.filepath)}`);
44
- });
45
- console.log(''); // Newline
46
- }
47
- }
48
- catch (error) {
49
- spinner.fail(chalk.red('Status check failed: ' + (error.message || 'Unknown error')));
50
- }
51
- });
52
- };
@@ -1,155 +0,0 @@
1
- import chalk from 'chalk';
2
- import ora from 'ora';
3
- import path from 'path';
4
- import { Api } from '../api/client.js'; // Note .js extension for ESM
5
- import { requireAuthAndOrg } from '../utils/session.js';
6
- import { printActiveOrg } from '../utils/org.js';
7
- import { getProjectData } from '../utils/project.js';
8
- export const taskCommands = (program) => {
9
- const taskCmd = program.command('task').description('Manage tasks');
10
- taskCmd
11
- .command('list')
12
- .description('List all tasks assigned to you')
13
- .action(async () => {
14
- const org = await requireAuthAndOrg();
15
- if (!org)
16
- return;
17
- const spinner = ora('Fetching projects...').start();
18
- try {
19
- // 1. Fetch Projects
20
- const projectRes = await Api.projects.list();
21
- const projects = projectRes.data.data;
22
- if (!projects || projects.length === 0) {
23
- spinner.stop();
24
- printActiveOrg(org);
25
- console.log(chalk.yellow('No projects found.'));
26
- return;
27
- }
28
- // Use existing spinner or start new activity
29
- if (spinner.isSpinning)
30
- spinner.stop();
31
- spinner.start('Fetching tasks...');
32
- let foundAnyTasks = false;
33
- // Loop through all projects to find tasks
34
- for (const project of projects) {
35
- spinner.text = `Checking project: ${project.name}...`;
36
- try {
37
- const taskRes = await Api.tasks.list(project.slug);
38
- const tasks = taskRes.data.data;
39
- if (tasks && tasks.length > 0) {
40
- if (!foundAnyTasks) {
41
- spinner.stop();
42
- foundAnyTasks = true;
43
- printActiveOrg(org);
44
- console.log(chalk.bold('\nYour Tasks:\n'));
45
- }
46
- // Print Project Header if we have tasks
47
- console.log(chalk.dim(`Project: ${project.name} (${project.slug})`));
48
- tasks.forEach((task) => {
49
- console.log(` ${chalk.cyan(task.slug)} - ${task.title} [${task.taskStatus}]`);
50
- });
51
- console.log('');
52
- }
53
- }
54
- catch (err) {
55
- // Ignore error for individual project fetch and continue
56
- }
57
- }
58
- if (!foundAnyTasks) {
59
- spinner.stop();
60
- printActiveOrg(org);
61
- console.log(chalk.yellow('No tasks found in any of your projects.'));
62
- }
63
- else {
64
- if (spinner.isSpinning)
65
- spinner.stop();
66
- }
67
- }
68
- catch (error) {
69
- spinner.fail(chalk.red('Failed to list tasks: ' + (error.message || 'Unknown error')));
70
- }
71
- });
72
- taskCmd
73
- .command('checkout <slug> [path]')
74
- .description('Checkout a task to local environment')
75
- .action(async (slug, pathArg) => {
76
- const org = await requireAuthAndOrg();
77
- if (!org)
78
- return;
79
- const spinner = ora(`Checking out task ${slug}...`).start();
80
- try {
81
- printActiveOrg(org);
82
- // Get Files (including .kodlyspec)
83
- const checkoutRes = await Api.tasks.checkout(slug);
84
- const files = checkoutRes.data.data; // Array of SyncCodeResultDto
85
- const taskDir = pathArg ? path.resolve(process.cwd(), pathArg) : path.resolve(process.cwd(), slug);
86
- const { syncCheckoutFiles } = await import('../utils/checkout.js');
87
- const success = await syncCheckoutFiles(taskDir, files, 'task', spinner);
88
- if (success) {
89
- spinner.succeed(chalk.green(`Task checked out to ${pathArg || './' + slug}`));
90
- console.log(`Files synchronized: ${files.length}`);
91
- }
92
- }
93
- catch (error) {
94
- spinner.fail(chalk.red(`Checkout failed: ${error.message || 'Unknown error'}`));
95
- }
96
- });
97
- taskCmd
98
- .command('create [args...]')
99
- .description('Create a new task for a project')
100
- .action(async (args) => {
101
- const org = await requireAuthAndOrg();
102
- if (!org)
103
- return;
104
- if (!args || args.length === 0) {
105
- console.log(chalk.red('Error: Task title is required.'));
106
- return;
107
- }
108
- let projectSlug = '';
109
- let title = '';
110
- const cwd = process.cwd();
111
- const projectData = getProjectData(cwd);
112
- if (projectData && projectData.projectSlug) {
113
- if (args.length === 1) {
114
- projectSlug = projectData.projectSlug;
115
- title = args[0];
116
- }
117
- else {
118
- // Check if first arg looks like a project slug and we have 2 args (e.g. `kodly task create my-project "Title"`)
119
- if (args.length === 2 && /^[a-z0-9-]+$/.test(args[0])) {
120
- projectSlug = args[0];
121
- title = args[1];
122
- }
123
- else {
124
- projectSlug = projectData.projectSlug;
125
- title = args.join(' ');
126
- }
127
- }
128
- }
129
- else {
130
- if (args.length < 2) {
131
- console.log(chalk.red('Error: <projectSlug> and <title> are required when not inside a project directory. Usage: kodly task create <projectSlug> <title...>'));
132
- return;
133
- }
134
- projectSlug = args[0];
135
- title = args.slice(1).join(' ');
136
- }
137
- const spinner = ora(`Creating task "${title}" in project ${projectSlug}...`).start();
138
- try {
139
- printActiveOrg(org);
140
- const createRes = await Api.tasks.create(projectSlug, title);
141
- const newTask = createRes.data.data;
142
- if (newTask) {
143
- spinner.succeed(chalk.green(`Task created successfully:`));
144
- console.log(` ${chalk.cyan(newTask.slug)} - ${newTask.title}`);
145
- console.log(`\nTo checkout this task, run:\n ${chalk.cyan(`kodly task checkout ${newTask.slug} .`)}\n`);
146
- }
147
- else {
148
- spinner.succeed(chalk.green(`Task created successfully.`));
149
- }
150
- }
151
- catch (error) {
152
- spinner.fail(chalk.red(`Failed to create task: ${error.message || 'Unknown error'}`));
153
- }
154
- });
155
- };
@@ -1,90 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- export async function getChangedFiles(cwd) {
4
- const crypto = await import('crypto');
5
- const ignore = (await import('ignore')).default;
6
- let ig = ignore();
7
- const gitignorePath = path.join(cwd, '.gitignore');
8
- if (fs.existsSync(gitignorePath)) {
9
- ig.add(fs.readFileSync(gitignorePath, 'utf8'));
10
- }
11
- // Always ignore .kodly, .git, and common lock files / spec files
12
- ig.add(['.kodly', '.git', 'node_modules', 'dist', 'build', '.kodlyspec', 'package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock', 'pnpm-lock.yaml']);
13
- const kodlyDir = path.join(cwd, '.kodly');
14
- const checksumsPath = path.join(kodlyDir, 'checksums.json');
15
- let storedChecksums = {};
16
- if (fs.existsSync(checksumsPath)) {
17
- const rawChecksums = JSON.parse(fs.readFileSync(checksumsPath, 'utf8'));
18
- // Normalize keys to ensure forward slashes
19
- Object.keys(rawChecksums).forEach(key => {
20
- storedChecksums[key.replace(/\\/g, '/')] = rawChecksums[key];
21
- });
22
- }
23
- const filesToPush = [];
24
- const newChecksums = { ...storedChecksums };
25
- const foundFiles = new Set();
26
- function scanDirectory(dir, base) {
27
- const list = fs.readdirSync(dir);
28
- list.forEach(file => {
29
- const fullPath = path.join(dir, file);
30
- const rawRelativePath = path.join(base, file);
31
- const relativePath = rawRelativePath.replace(/\\/g, '/'); // Ensure forward slashes
32
- // Check ignore
33
- if (ig.ignores(relativePath))
34
- return;
35
- const stat = fs.statSync(fullPath);
36
- if (stat.isDirectory()) {
37
- scanDirectory(fullPath, relativePath);
38
- }
39
- else {
40
- foundFiles.add(relativePath);
41
- const contentBuffer = fs.readFileSync(fullPath);
42
- const currentHash = crypto.createHash('md5').update(contentBuffer).digest('hex');
43
- // Check if file changed
44
- if (storedChecksums[relativePath] !== currentHash) {
45
- const content = contentBuffer.toString('utf8'); // Assuming text for now
46
- filesToPush.push({
47
- filepath: relativePath,
48
- content,
49
- base64Encoded: false,
50
- status: storedChecksums[relativePath] ? 'MODIFIED' : 'NEW',
51
- currentHash
52
- });
53
- // Update local map (pending successful push)
54
- newChecksums[relativePath] = currentHash;
55
- }
56
- else {
57
- // Keep existing hash (already copied via spread)
58
- }
59
- }
60
- });
61
- }
62
- scanDirectory(cwd, '');
63
- // Check for deleted files
64
- Object.keys(storedChecksums).forEach(path => {
65
- if (!foundFiles.has(path)) {
66
- if (ig.ignores(path)) {
67
- // If it's ignored locally now, stop tracking it but don't delete on server.
68
- delete newChecksums[path];
69
- }
70
- else {
71
- filesToPush.push({
72
- filepath: path,
73
- content: '', // Or null if API supports it, but interface says string
74
- base64Encoded: false,
75
- status: 'TO_BE_DELETED',
76
- currentHash: ''
77
- });
78
- delete newChecksums[path];
79
- }
80
- }
81
- });
82
- return { filesToPush, newChecksums };
83
- }
84
- export function updateChecksums(cwd, newChecksums) {
85
- const kodlyDir = path.join(cwd, '.kodly');
86
- const checksumsPath = path.join(kodlyDir, 'checksums.json');
87
- if (!fs.existsSync(kodlyDir))
88
- fs.mkdirSync(kodlyDir, { recursive: true });
89
- fs.writeFileSync(checksumsPath, JSON.stringify(newChecksums, null, 2));
90
- }
@@ -1,168 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import crypto from 'crypto';
4
- import chalk from 'chalk';
5
- import inquirer from 'inquirer';
6
- import ignore from 'ignore';
7
- export async function syncCheckoutFiles(targetDir, incomingFiles, entityName, spinner) {
8
- // Ensure target dir exists
9
- if (!fs.existsSync(targetDir)) {
10
- fs.mkdirSync(targetDir, { recursive: true });
11
- }
12
- const kodlyDir = path.join(targetDir, '.kodly');
13
- if (!fs.existsSync(kodlyDir)) {
14
- fs.mkdirSync(kodlyDir, { recursive: true });
15
- }
16
- // 1. Prepare ignore rules
17
- let ig = ignore();
18
- const gitignorePath = path.join(targetDir, '.gitignore');
19
- if (fs.existsSync(gitignorePath)) {
20
- ig.add(fs.readFileSync(gitignorePath, 'utf8'));
21
- }
22
- // Always ignore .kodly, .git, and common build dirs
23
- ig.add(['.kodly', '.git', 'node_modules', 'dist', 'build', '.kodly-docs.json', '.kodlyspec', 'package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock', 'pnpm-lock.yaml']);
24
- // 2. Process incoming files and compute hashes
25
- const incomingMap = {};
26
- incomingFiles.forEach((file) => {
27
- const relativePath = file.basePath ? file.basePath.replace(/^\//, '') : '';
28
- const fileNameFull = file.fileName;
29
- const key = relativePath ? path.posix.join(relativePath, fileNameFull) : fileNameFull;
30
- let fileBuffer;
31
- if (file.isBase64Encoded) {
32
- fileBuffer = Buffer.from(file.content || '', 'base64');
33
- }
34
- else {
35
- fileBuffer = Buffer.from(file.content || '');
36
- }
37
- const hash = crypto.createHash('md5').update(fileBuffer).digest('hex');
38
- incomingMap[key] = {
39
- content: fileBuffer,
40
- hash,
41
- isBase64: file.isBase64Encoded
42
- };
43
- });
44
- // 3. Scan local files
45
- const localFiles = scanDirectory(targetDir, '', ig);
46
- const localMap = {}; // filepath -> hash
47
- localFiles.forEach(subPath => {
48
- const fullPath = path.join(targetDir, subPath);
49
- const contentBuffer = fs.readFileSync(fullPath);
50
- const hash = crypto.createHash('md5').update(contentBuffer).digest('hex');
51
- localMap[subPath] = hash;
52
- });
53
- // 4. Compute Changeset
54
- const changes = [];
55
- const newChecksums = {};
56
- // Check incoming files (NEW, MODIFIED, UNCHANGED)
57
- Object.keys(incomingMap).forEach(incomingKey => {
58
- newChecksums[incomingKey] = incomingMap[incomingKey].hash;
59
- if (!localMap[incomingKey]) {
60
- changes.push({ filepath: incomingKey, status: 'NEW' });
61
- }
62
- else if (localMap[incomingKey] !== incomingMap[incomingKey].hash) {
63
- changes.push({ filepath: incomingKey, status: 'MODIFIED' });
64
- }
65
- else {
66
- changes.push({ filepath: incomingKey, status: 'UNCHANGED' });
67
- }
68
- });
69
- // Check local files (TO_BE_DELETED)
70
- Object.keys(localMap).forEach(localKey => {
71
- if (!incomingMap[localKey]) {
72
- changes.push({ filepath: localKey, status: 'TO_BE_DELETED' });
73
- }
74
- });
75
- // 5. Present changeset
76
- const actionableChanges = changes.filter(c => c.status !== 'UNCHANGED');
77
- if (actionableChanges.length === 0) {
78
- // No changes needed, just write checksums
79
- fs.writeFileSync(path.join(kodlyDir, 'checksums.json'), JSON.stringify(newChecksums, null, 2));
80
- return true; // No prompts needed, proceed as success
81
- }
82
- const isFreshCheckout = Object.keys(localMap).length === 0;
83
- if (!isFreshCheckout) {
84
- spinner.stop(); // Stop spinner to prompt user
85
- console.log(chalk.bold(`\nChangeset for ${entityName}:`));
86
- actionableChanges.sort((a, b) => a.filepath.localeCompare(b.filepath)).forEach(file => {
87
- let color = chalk.yellow;
88
- if (file.status === 'NEW')
89
- color = chalk.green;
90
- if (file.status === 'TO_BE_DELETED')
91
- color = chalk.red;
92
- let prefix = '';
93
- if (file.status === 'NEW')
94
- prefix = '+';
95
- else if (file.status === 'MODIFIED')
96
- prefix = 'M';
97
- else if (file.status === 'TO_BE_DELETED')
98
- prefix = '-';
99
- console.log(` ${color(prefix)} ${file.filepath}`);
100
- });
101
- console.log('');
102
- // 6. Prompt user
103
- const { confirm } = await inquirer.prompt([{
104
- type: 'confirm',
105
- name: 'confirm',
106
- message: 'Do you want to apply these changes?',
107
- default: true
108
- }]);
109
- if (!confirm) {
110
- console.log(chalk.yellow('Checkout aborted by user.'));
111
- return false;
112
- }
113
- spinner.start('Applying changes...');
114
- }
115
- // 7. Apply Changes
116
- // Write NEW and MODIFIED files
117
- const incomingToApply = changes.filter(c => c.status === 'NEW' || c.status === 'MODIFIED' || c.status === 'UNCHANGED');
118
- incomingToApply.forEach(c => {
119
- const fullPath = path.join(targetDir, c.filepath);
120
- const dirName = path.dirname(fullPath);
121
- if (!fs.existsSync(dirName)) {
122
- fs.mkdirSync(dirName, { recursive: true });
123
- }
124
- fs.writeFileSync(fullPath, incomingMap[c.filepath].content);
125
- });
126
- // Delete TO_BE_DELETED files
127
- const toDelete = changes.filter(c => c.status === 'TO_BE_DELETED');
128
- toDelete.forEach(c => {
129
- const fullPath = path.join(targetDir, c.filepath);
130
- if (fs.existsSync(fullPath)) {
131
- fs.unlinkSync(fullPath);
132
- // Optionally, try to remove empty directory
133
- const dirName = path.dirname(fullPath);
134
- removeEmptyDirs(dirName, targetDir);
135
- }
136
- });
137
- // Write Checksums
138
- fs.writeFileSync(path.join(kodlyDir, 'checksums.json'), JSON.stringify(newChecksums, null, 2));
139
- return true; // Applied successfully
140
- }
141
- function scanDirectory(dir, base, ig) {
142
- const list = fs.readdirSync(dir);
143
- const results = [];
144
- list.forEach(file => {
145
- const fullPath = path.join(dir, file);
146
- const rawRelativePath = path.join(base, file);
147
- const relativePath = rawRelativePath.replace(/\\/g, '/'); // forward slashes
148
- if (ig.ignores(relativePath))
149
- return;
150
- const stat = fs.statSync(fullPath);
151
- if (stat.isDirectory()) {
152
- results.push(...scanDirectory(fullPath, relativePath, ig));
153
- }
154
- else {
155
- results.push(relativePath);
156
- }
157
- });
158
- return results;
159
- }
160
- function removeEmptyDirs(dir, stopAt) {
161
- if (dir === stopAt || !fs.existsSync(dir))
162
- return;
163
- const files = fs.readdirSync(dir);
164
- if (files.length === 0) {
165
- fs.rmdirSync(dir);
166
- removeEmptyDirs(path.dirname(dir), stopAt);
167
- }
168
- }
@@ -1,34 +0,0 @@
1
- import Conf from 'conf';
2
- const config = new Conf({
3
- projectName: 'nokode-cli',
4
- });
5
- export const getAuthToken = () => {
6
- return config.get('authToken');
7
- };
8
- export const setAuthToken = (token) => {
9
- config.set('authToken', token);
10
- };
11
- export const clearAuthToken = () => {
12
- config.delete('authToken');
13
- };
14
- export const getOrgSlug = () => {
15
- return config.get('orgSlug');
16
- };
17
- export const setOrgSlug = (slug) => {
18
- config.set('orgSlug', slug);
19
- };
20
- export const clearOrgSlug = () => {
21
- config.delete('orgSlug');
22
- };
23
- export const getUpdateCheckCache = () => {
24
- const lastCheckedAt = config.get('updateCheck.lastCheckedAt');
25
- const latestVersion = config.get('updateCheck.latestVersion');
26
- if (typeof lastCheckedAt !== 'number' || typeof latestVersion !== 'string') {
27
- return undefined;
28
- }
29
- return { lastCheckedAt, latestVersion };
30
- };
31
- export const setUpdateCheckCache = (cache) => {
32
- config.set('updateCheck.lastCheckedAt', cache.lastCheckedAt);
33
- config.set('updateCheck.latestVersion', cache.latestVersion);
34
- };