puter-cli 1.5.2 → 1.5.3
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/CHANGELOG.md +11 -0
- package/README.md +12 -12
- package/package.json +1 -1
- package/src/commands/sites.js +4 -4
- package/src/executor.js +12 -7
- package/src/utils.js +21 -1
- package/tests/utils.test.js +192 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v1.5.3](https://github.com/HeyPuter/puter-cli/compare/v1.5.2...v1.5.3)
|
|
8
|
+
|
|
9
|
+
- refactor: early return in fallback behavior [`#6`](https://github.com/HeyPuter/puter-cli/pull/6)
|
|
10
|
+
- fix: ignore undefined appDir when listing sites [`#5`](https://github.com/HeyPuter/puter-cli/pull/5)
|
|
11
|
+
- fix: use array args when calling DeleteSubdomain [`#4`](https://github.com/HeyPuter/puter-cli/pull/4)
|
|
12
|
+
- Update README.md [`#3`](https://github.com/HeyPuter/puter-cli/pull/3)
|
|
13
|
+
- fix: improve app uuid check [`49dcc7f`](https://github.com/HeyPuter/puter-cli/commit/49dcc7f1220a58987601e8054b0d4a450cd02afe)
|
|
14
|
+
- fix: potential timezone issues [`ba0e4b1`](https://github.com/HeyPuter/puter-cli/commit/ba0e4b183efb82a0c252e5c6250d976f1efe19cd)
|
|
15
|
+
|
|
7
16
|
#### [v1.5.2](https://github.com/HeyPuter/puter-cli/compare/v1.5.1...v1.5.2)
|
|
8
17
|
|
|
18
|
+
> 6 February 2025
|
|
19
|
+
|
|
9
20
|
- chore: clean unused [`e5c7fcc`](https://github.com/HeyPuter/puter-cli/commit/e5c7fcca3096b4b2c0659d84d8de63dce039a765)
|
|
10
21
|
- chore: more details [`0a25a2f`](https://github.com/HeyPuter/puter-cli/commit/0a25a2fb7efa9a67033b4e483305da44a68f2c9a)
|
|
11
22
|
- docs: badge version [`503bc66`](https://github.com/HeyPuter/puter-cli/commit/503bc6667666b14f85245887a3bf2071711dc4e1)
|
package/README.md
CHANGED
|
@@ -53,12 +53,12 @@ puter --version
|
|
|
53
53
|
|
|
54
54
|
### Commands
|
|
55
55
|
|
|
56
|
-
####
|
|
57
|
-
- **Create a new project**:
|
|
56
|
+
#### Initialize a project
|
|
57
|
+
- **Create a new project**: Initialize a new project
|
|
58
58
|
```bash
|
|
59
59
|
puter init
|
|
60
60
|
```
|
|
61
|
-
Then just follow the prompts, this command doesn't require you to
|
|
61
|
+
Then just follow the prompts, this command doesn't require you to log in.
|
|
62
62
|
|
|
63
63
|
#### Authentication
|
|
64
64
|
- **Login**: Log in to your Puter account.
|
|
@@ -72,7 +72,7 @@ Then just follow the prompts, this command doesn't require you to login.
|
|
|
72
72
|
|
|
73
73
|
#### File Management
|
|
74
74
|
|
|
75
|
-
We've adopted the most basic
|
|
75
|
+
We've adopted the most basic popular Linux system command line for daily file manipulation with some extra features, not out of the box though, we want to keep it simple.
|
|
76
76
|
|
|
77
77
|
- **List Files**: List files and directories.
|
|
78
78
|
```bash
|
|
@@ -157,7 +157,7 @@ P.S. Please check the help command `help apps` for more details about any argume
|
|
|
157
157
|
```bash
|
|
158
158
|
puter> app:create <name> [<directory>] [--description="My App Description"] [--url=<url>]
|
|
159
159
|
```
|
|
160
|
-
P.S. By default a new `index.html` with basic content will be created, but you can set a directory when you create a new application as follows: `app:create nameOfApp ./appDir`, so all files will be copied to the `AppData`
|
|
160
|
+
P.S. By default a new `index.html` with basic content will be created, but you can set a directory when you create a new application as follows: `app:create nameOfApp ./appDir`, so all files will be copied to the `AppData` directory, you can then update your app using `app:update <name> <remote_dir>`. This command will attempt to create a subdomain with a random `uid` prefixed with the name of the app.
|
|
161
161
|
|
|
162
162
|
- **Update Application**: Update an application.
|
|
163
163
|
```bash
|
|
@@ -169,7 +169,7 @@ P.S. By default a new `index.html` with basic content will be created, but you c
|
|
|
169
169
|
```bash
|
|
170
170
|
puter> app:delete [-f] <name>
|
|
171
171
|
```
|
|
172
|
-
P.S. This command will
|
|
172
|
+
P.S. This command will look for the allocated `subdomain` and attempt to delete it if it exists.
|
|
173
173
|
|
|
174
174
|
#### Static Sites
|
|
175
175
|
|
|
@@ -179,7 +179,7 @@ The static sites are served from the selected directory (or the current director
|
|
|
179
179
|
```bash
|
|
180
180
|
puter> site:create <app_name> [<dir>] [--subdomain=<name>]
|
|
181
181
|
```
|
|
182
|
-
P.S. If the subdomain already exists, it will generate a new random one can set your own subdomain using `--subdomain` argument.
|
|
182
|
+
P.S. If the subdomain already exists, it will generate a new random one. You can set your own subdomain using `--subdomain` argument.
|
|
183
183
|
|
|
184
184
|
- **List Sites**: List all hosted sites.
|
|
185
185
|
```bash
|
|
@@ -282,7 +282,7 @@ If you want to customize this tool you can follow these steps:
|
|
|
282
282
|
|
|
283
283
|
## Known issues:
|
|
284
284
|
|
|
285
|
-
Most of the functionalities are just working fine, however some APIs related to Puter's SDK have some known issues. We tried to fix most them but some of them are not related to us, so we let you about that in case it'll be fixed by Puter's in the future:
|
|
285
|
+
Most of the functionalities are just working fine, however, some APIs related to Puter's SDK have some known issues. We tried to fix most of them but some of them are not related to us, so we let you about that in case it'll be fixed by Puter's in the future:
|
|
286
286
|
|
|
287
287
|
## Delete a subdomain
|
|
288
288
|
When you try to delete a subdomain which you own, you'll get `Permission denied`:
|
|
@@ -290,7 +290,7 @@ When you try to delete a subdomain which you own, you'll get `Permission denied`
|
|
|
290
290
|
Failed to delete subdomain: Permission denied.
|
|
291
291
|
Site ID: "sd-b019b654-e06f-48a8-917e-ae1e83825ab7" may already be deleted!
|
|
292
292
|
```
|
|
293
|
-
However, the query is executed successfully
|
|
293
|
+
However, the query is executed successfully in the cloud and the subdomain is actually deleted.
|
|
294
294
|
|
|
295
295
|
## Interactive Shell prompt:
|
|
296
296
|
If you want to stay in the interactive shell you should provide "-f" (aka: force delete) argument, when want to delete any object:
|
|
@@ -310,7 +310,7 @@ Otherwise, the Interactive Shell mode will be terminated.
|
|
|
310
310
|
|
|
311
311
|
## Notes
|
|
312
312
|
|
|
313
|
-
This project is not equivalent [phoenix](https://github.com/HeyPuter/puter/blob/main/src/phoenix/README.md),
|
|
313
|
+
This project is not equivalent [phoenix](https://github.com/HeyPuter/puter/blob/main/src/phoenix/README.md), neither an attempt to mimic some of its features, it's rather a CLI tool to do most the Puter's API from the command line.
|
|
314
314
|
|
|
315
315
|
---
|
|
316
316
|
|
|
@@ -324,7 +324,7 @@ The CLI uses a configuration file to store user credentials and settings. You ca
|
|
|
324
324
|
|
|
325
325
|
We welcome contributions! Please follow these steps:
|
|
326
326
|
1. Fork the repository.
|
|
327
|
-
2. Create a new branch for your feature or bugfix with
|
|
327
|
+
2. Create a new branch for your feature or bugfix with reproducible steps.
|
|
328
328
|
3. Submit a pull request with a detailed description of your changes.
|
|
329
329
|
|
|
330
330
|
---
|
|
@@ -355,4 +355,4 @@ For issues or questions, please open an issue on [GitHub](https://github.com/bit
|
|
|
355
355
|
---
|
|
356
356
|
|
|
357
357
|
|
|
358
|
-
Happy
|
|
358
|
+
Happy deploying with **Puter CLI**! 🚀
|
package/package.json
CHANGED
package/src/commands/sites.js
CHANGED
|
@@ -3,7 +3,7 @@ import fetch from 'node-fetch';
|
|
|
3
3
|
import Table from 'cli-table3';
|
|
4
4
|
import { getCurrentUserName, getCurrentDirectory } from './auth.js';
|
|
5
5
|
import { API_BASE, getHeaders, generateAppName, resolvePath, isValidAppName } from '../commons.js';
|
|
6
|
-
import { displayNonNullValues, formatDate,
|
|
6
|
+
import { displayNonNullValues, formatDate, isValidAppUuid } from '../utils.js';
|
|
7
7
|
import { getSubdomains, createSubdomain, deleteSubdomain } from './subdomains.js';
|
|
8
8
|
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@ export async function listSites(args = {}) {
|
|
|
43
43
|
formatDate(domain.created_at).split(',')[0],
|
|
44
44
|
domain.protected ? chalk.red('Yes') : chalk.green('No'),
|
|
45
45
|
// domain.owner['username'],
|
|
46
|
-
appDir
|
|
46
|
+
appDir && (isValidAppUuid(appDir.join('-'))?`${appDir[0]}-...-${appDir.slice(-1)}`:appDir.join('-'))
|
|
47
47
|
]);
|
|
48
48
|
});
|
|
49
49
|
|
|
@@ -121,7 +121,7 @@ export async function infoSite(args = []) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
const data = await response.json();
|
|
124
|
-
const result = await deleteSubdomain(uuid);
|
|
124
|
+
const result = await deleteSubdomain([uuid]);
|
|
125
125
|
if (result){
|
|
126
126
|
// check if data is empty object
|
|
127
127
|
if (Object.keys(data).length === 0){
|
|
@@ -183,7 +183,7 @@ export async function infoSite(args = []) {
|
|
|
183
183
|
} else {
|
|
184
184
|
console.log(chalk.yellow(`However, It's linked to different directory at: ${subdomainObj.root_dir?.path}`));
|
|
185
185
|
console.log(chalk.cyan(`We'll try to unlink this subdomain from that directory...`));
|
|
186
|
-
const result = await deleteSubdomain(subdomainObj?.uid);
|
|
186
|
+
const result = await deleteSubdomain([subdomainObj?.uid]);
|
|
187
187
|
if (result) {
|
|
188
188
|
console.log(chalk.green('Looks like this subdomain is free again, please try again.'));
|
|
189
189
|
return;
|
package/src/executor.js
CHANGED
|
@@ -163,7 +163,9 @@ export async function execCommand(input) {
|
|
|
163
163
|
// Handle help command
|
|
164
164
|
const command = args[0];
|
|
165
165
|
showHelp(command);
|
|
166
|
-
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (cmd.startsWith('!')) {
|
|
167
169
|
// Execute the command on the host machine
|
|
168
170
|
const hostCommand = input.slice(1); // Remove the "!"
|
|
169
171
|
exec(hostCommand, (error, stdout, stderr) => {
|
|
@@ -178,17 +180,20 @@ export async function execCommand(input) {
|
|
|
178
180
|
console.log(stdout);
|
|
179
181
|
console.log(chalk.green(`Press <Enter> to return.`));
|
|
180
182
|
});
|
|
181
|
-
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (commands[cmd]) {
|
|
182
186
|
try {
|
|
183
187
|
await commands[cmd](args);
|
|
184
188
|
} catch (error) {
|
|
185
189
|
console.error(chalk.red(`Error executing command: ${error.message}`));
|
|
186
190
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (!['Y', 'N'].includes(cmd.toUpperCase()[0])) {
|
|
195
|
+
console.log(chalk.red(`Unknown command: ${cmd}`));
|
|
196
|
+
showHelp();
|
|
192
197
|
}
|
|
193
198
|
}
|
|
194
199
|
|
package/src/utils.js
CHANGED
|
@@ -15,7 +15,8 @@ export function formatDate(value) {
|
|
|
15
15
|
hour: "2-digit",
|
|
16
16
|
minute: "2-digit",
|
|
17
17
|
second: "2-digit",
|
|
18
|
-
hour12: false
|
|
18
|
+
hour12: false,
|
|
19
|
+
timeZone: 'UTC'
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -100,4 +101,23 @@ export function displayNonNullValues(data) {
|
|
|
100
101
|
export function parseArgs(input, options = {}) {
|
|
101
102
|
const result = yargsParser(input, options);
|
|
102
103
|
return result;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Checks if a given string is a valid UUID of any version
|
|
108
|
+
* @param {string} uuid - The string to validate.
|
|
109
|
+
* @returns {boolean} - True if the string is a valid UUID, false otherwise.
|
|
110
|
+
*/
|
|
111
|
+
export function isValidAppUuid (uuid) {
|
|
112
|
+
return uuid.startsWith('app-') && is_valid_uuid4(uuid.slice(4));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Checks if a given string is a valid UUID version 4.
|
|
117
|
+
* @param {string} uuid - The string to validate.
|
|
118
|
+
* @returns {boolean} - True if the string is a valid UUID version 4, false otherwise.
|
|
119
|
+
*/
|
|
120
|
+
export function is_valid_uuid4 (uuid) {
|
|
121
|
+
const uuidV4Regex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
122
|
+
return uuidV4Regex.test(uuid);
|
|
103
123
|
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { formatDate, formatDateTime, formatSize, displayNonNullValues, parseArgs, isValidAppUuid, is_valid_uuid4 } from '../src/utils.js';
|
|
3
|
+
|
|
4
|
+
describe('formatDate', () => {
|
|
5
|
+
it('should format a date string correctly', () => {
|
|
6
|
+
const dateString = '2024-10-07T15:03:53.000Z';
|
|
7
|
+
const expected = '10/07/2024, 15:03:53';
|
|
8
|
+
expect(formatDate(dateString)).toBe(expected);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should format a date object correctly', () => {
|
|
12
|
+
const dateObject = new Date(Date.UTC(2024, 9, 7, 15, 3, 53)); // Month is 0-indexed
|
|
13
|
+
const expected = '10/07/2024, 15:03:53';
|
|
14
|
+
expect(formatDate(dateObject)).toBe(expected);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should handle different date and time', () => {
|
|
18
|
+
const dateString = '2023-01-01T00:00:00.000Z';
|
|
19
|
+
const expected = '01/01/2023, 24:00:00';
|
|
20
|
+
expect(formatDate(dateString)).toBe(expected);
|
|
21
|
+
});
|
|
22
|
+
it('should handle invalid date', () => {
|
|
23
|
+
const dateString = 'invalid-date';
|
|
24
|
+
expect(formatDate(dateString)).toBe('Invalid Date');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('formatDateTime', () => {
|
|
29
|
+
it('should format as time if within 24 hours', () => {
|
|
30
|
+
const now = new Date();
|
|
31
|
+
const timestamp = Math.floor(now.getTime() / 1000) - 3600; // 1 hour ago
|
|
32
|
+
const expected = new Date(timestamp * 1000).toLocaleTimeString();
|
|
33
|
+
expect(formatDateTime(timestamp)).toBe(expected);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should format as date if older than 24 hours', () => {
|
|
37
|
+
const timestamp = Math.floor(Date.now() / 1000) - 86400 * 2; // 2 days ago
|
|
38
|
+
const expected = new Date(timestamp * 1000).toLocaleDateString();
|
|
39
|
+
expect(formatDateTime(timestamp)).toBe(expected);
|
|
40
|
+
});
|
|
41
|
+
it('should format timestamp 0', () => {
|
|
42
|
+
const timestamp = 0;
|
|
43
|
+
const expected = new Date(timestamp * 1000).toLocaleDateString();
|
|
44
|
+
expect(formatDateTime(timestamp)).toBe(expected);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('formatSize', () => {
|
|
49
|
+
it('should format 0 bytes correctly', () => {
|
|
50
|
+
expect(formatSize(0)).toBe('0');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should format bytes correctly', () => {
|
|
54
|
+
expect(formatSize(512)).toBe('512.0 B');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should format kilobytes correctly', () => {
|
|
58
|
+
expect(formatSize(1024 * 2)).toBe('2.0 KB');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should format megabytes correctly', () => {
|
|
62
|
+
expect(formatSize(1024 * 1024 * 3)).toBe('3.0 MB');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should format gigabytes correctly', () => {
|
|
66
|
+
expect(formatSize(1024 * 1024 * 1024 * 4)).toBe('4.0 GB');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should format terabytes correctly', () => {
|
|
70
|
+
expect(formatSize(1024 * 1024 * 1024 * 1024 * 5)).toBe('5.0 TB');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should handle null and undefined', () => {
|
|
74
|
+
expect(formatSize(null)).toBe('0');
|
|
75
|
+
expect(formatSize(undefined)).toBe('0');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('displayNonNullValues', () => {
|
|
80
|
+
it('should display non-null values in a formatted table', () => {
|
|
81
|
+
const data = {
|
|
82
|
+
name: 'John Doe',
|
|
83
|
+
age: 30,
|
|
84
|
+
address: {
|
|
85
|
+
street: '123 Main St',
|
|
86
|
+
city: 'Anytown',
|
|
87
|
+
zip: null
|
|
88
|
+
},
|
|
89
|
+
email: null
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const consoleLogSpy = vi.spyOn(console, 'log');
|
|
93
|
+
displayNonNullValues(data);
|
|
94
|
+
expect(consoleLogSpy).toHaveBeenCalled();
|
|
95
|
+
consoleLogSpy.mockRestore();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should handle empty object', () => {
|
|
99
|
+
const data = {};
|
|
100
|
+
const consoleLogSpy = vi.spyOn(console, 'log');
|
|
101
|
+
displayNonNullValues(data);
|
|
102
|
+
expect(consoleLogSpy).toHaveBeenCalled();
|
|
103
|
+
consoleLogSpy.mockRestore();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should handle nested objects with all null values', () => {
|
|
107
|
+
const data = { a: null, b: { c: null, d: null } };
|
|
108
|
+
const consoleLogSpy = vi.spyOn(console, 'log');
|
|
109
|
+
displayNonNullValues(data);
|
|
110
|
+
expect(consoleLogSpy).toHaveBeenCalledTimes(5);
|
|
111
|
+
consoleLogSpy.mockRestore();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('should handle non-object input', () => {
|
|
115
|
+
const data = "not an object";
|
|
116
|
+
const consoleErrorSpy = vi.spyOn(console, 'error');
|
|
117
|
+
displayNonNullValues(data);
|
|
118
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("Invalid input: Input must be a non-null object.");
|
|
119
|
+
consoleErrorSpy.mockRestore();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('parseArgs', () => {
|
|
124
|
+
it('should parse simple arguments', () => {
|
|
125
|
+
const input = 'command --arg1 val1 --arg2 val2';
|
|
126
|
+
const expected = { _: ['command'], arg1: 'val1', arg2: 'val2' };
|
|
127
|
+
expect(parseArgs(input)).toEqual(expect.objectContaining(expected));
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should parse command line arguments with different types', () => {
|
|
131
|
+
const input = 'command --name="John Doe" --age=30';
|
|
132
|
+
const result = parseArgs(input);
|
|
133
|
+
expect(result).toEqual({ _: ['command'], name: 'John Doe', age: 30 });
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('should parse quoted arguments', () => {
|
|
137
|
+
const input = 'command --arg "quoted value"';
|
|
138
|
+
const expected = { _: ['command'], arg: 'quoted value' };
|
|
139
|
+
expect(parseArgs(input)).toEqual(expect.objectContaining(expected));
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should parse arguments with equals sign', () => {
|
|
143
|
+
const input = 'command --arg1=val1 --arg2=val2';
|
|
144
|
+
const expected = { _: ['command'], arg1: 'val1', arg2: 'val2' };
|
|
145
|
+
expect(parseArgs(input)).toEqual(expect.objectContaining(expected));
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('should handle empty input', () => {
|
|
149
|
+
const result = parseArgs('');
|
|
150
|
+
expect(result).toEqual({ _: []});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should parse empty arguments', () => {
|
|
154
|
+
const input = '';
|
|
155
|
+
const expected = { _: [] };
|
|
156
|
+
expect(parseArgs(input)).toEqual(expect.objectContaining(expected));
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe('isValidAppUuid', () => {
|
|
161
|
+
it('should return true for a valid app UUID', () => {
|
|
162
|
+
const uuid = 'app-a1b2c3d4-e5f6-4789-8abc-def012345678';
|
|
163
|
+
expect(isValidAppUuid(uuid)).toBe(true);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('should return false if UUID does not start with "app-"', () => {
|
|
167
|
+
const uuid = 'a1b2c3d4-e5f6-4789-8abc-def012345678';
|
|
168
|
+
expect(isValidAppUuid(uuid)).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('should return false for an invalid UUID after "app-"', () => {
|
|
172
|
+
const uuid = 'app-invalid-uuid';
|
|
173
|
+
expect(isValidAppUuid(uuid)).toBe(false);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
describe('is_valid_uuid4', () => {
|
|
178
|
+
it('should return true for a valid UUID v4', () => {
|
|
179
|
+
const uuid = 'a1b2c3d4-e5f6-4789-8abc-def012345678';
|
|
180
|
+
expect(is_valid_uuid4(uuid)).toBe(true);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('should return false for an invalid UUID v4', () => {
|
|
184
|
+
const uuid = 'a1b2c3d4-e5f6-5789-8abc-def012345678'; // Invalid version
|
|
185
|
+
expect(is_valid_uuid4(uuid)).toBe(false);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('should return false for a completely invalid UUID', () => {
|
|
189
|
+
const uuid = 'invalid-uuid';
|
|
190
|
+
expect(is_valid_uuid4(uuid)).toBe(false);
|
|
191
|
+
});
|
|
192
|
+
});
|