@profoundlogic/coderflow-cli 0.3.2 → 0.4.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/lib/commands/license.js +26 -22
- package/lib/commands/list.js +2 -1
- package/lib/commands/status.js +2 -0
- package/package.json +1 -1
package/lib/commands/license.js
CHANGED
|
@@ -4,8 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { promises as fs } from 'fs';
|
|
6
6
|
import path from 'path';
|
|
7
|
+
import os from 'os';
|
|
7
8
|
import { getCoderSetupPath } from '../config.js';
|
|
8
9
|
|
|
10
|
+
function getDataDir() {
|
|
11
|
+
return process.env.SERVER_DATA_PATH || path.join(os.homedir(), '.coder', 'data');
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
/**
|
|
10
15
|
* Handle license command
|
|
11
16
|
* Usage:
|
|
@@ -63,19 +68,8 @@ async function setLicense(key) {
|
|
|
63
68
|
process.exit(1);
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
console.error('Error: CODER_SETUP_PATH not set');
|
|
69
|
-
console.error('');
|
|
70
|
-
console.error('The license file must be saved to your coder-setup directory.');
|
|
71
|
-
console.error('Set it with:');
|
|
72
|
-
console.error(' export CODER_SETUP_PATH=/path/to/coder-setup');
|
|
73
|
-
console.error('Or save to config:');
|
|
74
|
-
console.error(' coder server init /path/to/coder-setup');
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const licensePath = path.join(setupPath, 'license.json');
|
|
71
|
+
const dataDir = getDataDir();
|
|
72
|
+
const licensePath = path.join(dataDir, 'license.json');
|
|
79
73
|
|
|
80
74
|
// Create license data
|
|
81
75
|
const licenseData = {
|
|
@@ -83,8 +77,11 @@ async function setLicense(key) {
|
|
|
83
77
|
installedAt: new Date().toISOString()
|
|
84
78
|
};
|
|
85
79
|
|
|
80
|
+
// Ensure data directory exists
|
|
81
|
+
await fs.mkdir(dataDir, { recursive: true });
|
|
82
|
+
|
|
86
83
|
// Write license file
|
|
87
|
-
await fs.writeFile(licensePath, JSON.stringify(licenseData, null, 2),
|
|
84
|
+
await fs.writeFile(licensePath, JSON.stringify(licenseData, null, 2), { mode: 0o600 });
|
|
88
85
|
|
|
89
86
|
console.log('License installed successfully');
|
|
90
87
|
console.log(` Location: ${licensePath}`);
|
|
@@ -93,16 +90,23 @@ async function setLicense(key) {
|
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
async function showLicense() {
|
|
93
|
+
const dataDir = getDataDir();
|
|
96
94
|
const setupPath = await getCoderSetupPath();
|
|
97
|
-
if (!setupPath) {
|
|
98
|
-
console.error('Error: CODER_SETUP_PATH not set');
|
|
99
|
-
console.error('');
|
|
100
|
-
console.error('Set it with:');
|
|
101
|
-
console.error(' export CODER_SETUP_PATH=/path/to/coder-setup');
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
104
95
|
|
|
105
|
-
|
|
96
|
+
// Try DATA_DIR first, then fall back to setup path
|
|
97
|
+
let licensePath = path.join(dataDir, 'license.json');
|
|
98
|
+
try {
|
|
99
|
+
await fs.access(licensePath);
|
|
100
|
+
} catch {
|
|
101
|
+
if (!setupPath) {
|
|
102
|
+
console.log('No license installed');
|
|
103
|
+
console.log('');
|
|
104
|
+
console.log('Install a license with:');
|
|
105
|
+
console.log(' coder license set <key>');
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
licensePath = path.join(setupPath, 'license.json');
|
|
109
|
+
}
|
|
106
110
|
|
|
107
111
|
try {
|
|
108
112
|
const content = await fs.readFile(licensePath, 'utf-8');
|
package/lib/commands/list.js
CHANGED
|
@@ -22,7 +22,7 @@ function parseListArgs(args = []) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
console.error(`Error: Unknown option ${arg}`);
|
|
25
|
-
console.error('Usage: coder list [--status=running|completed|failed|rejected] [--environment=name]');
|
|
25
|
+
console.error('Usage: coder list [--status=running|completed|interrupted|failed|rejected] [--environment=name]');
|
|
26
26
|
process.exit(1);
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -77,6 +77,7 @@ export async function listTasks(args = []) {
|
|
|
77
77
|
|
|
78
78
|
for (const task of data.tasks) {
|
|
79
79
|
const statusIcon = task.status === 'completed' ? '✓'
|
|
80
|
+
: task.status === 'interrupted' ? '⏹'
|
|
80
81
|
: task.status === 'failed' ? '✗'
|
|
81
82
|
: task.status === 'rejected' ? '!' : '⋯';
|
|
82
83
|
|
package/lib/commands/status.js
CHANGED
|
@@ -31,6 +31,8 @@ export async function getStatus(taskId) {
|
|
|
31
31
|
if (data.status === 'completed') {
|
|
32
32
|
console.log(`\n✓ Task completed successfully`);
|
|
33
33
|
console.log(`Use "coder results ${taskId}" to get full results`);
|
|
34
|
+
} else if (data.status === 'interrupted') {
|
|
35
|
+
console.log(`\n⏹ Task interrupted`);
|
|
34
36
|
} else if (data.status === 'failed') {
|
|
35
37
|
console.log(`\n✗ Task failed`);
|
|
36
38
|
} else if (data.status === 'running') {
|