@sembix/cli 1.5.0 → 1.6.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/README.md +556 -2267
- package/USAGE-EXAMPLES.md +466 -1
- package/config.example.yaml +16 -0
- package/dist/commands/customer-portal.d.ts +3 -0
- package/dist/commands/customer-portal.d.ts.map +1 -0
- package/dist/commands/customer-portal.js +146 -0
- package/dist/commands/customer-portal.js.map +1 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +80 -6
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +42 -2
- package/dist/commands/workflow.js.map +1 -1
- package/dist/config-schema.d.ts +13 -0
- package/dist/config-schema.d.ts.map +1 -1
- package/dist/config-schema.js +17 -0
- package/dist/config-schema.js.map +1 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/prompts/customer-portal-step.d.ts +7 -0
- package/dist/prompts/customer-portal-step.d.ts.map +1 -0
- package/dist/prompts/customer-portal-step.js +154 -0
- package/dist/prompts/customer-portal-step.js.map +1 -0
- package/dist/prompts/customer-portal.d.ts +4 -0
- package/dist/prompts/customer-portal.d.ts.map +1 -0
- package/dist/prompts/customer-portal.js +210 -0
- package/dist/prompts/customer-portal.js.map +1 -0
- package/dist/prompts/workflow-inputs.d.ts.map +1 -1
- package/dist/prompts/workflow-inputs.js +6 -2
- package/dist/prompts/workflow-inputs.js.map +1 -1
- package/dist/sembix-cli-1.6.0.tgz +0 -0
- package/dist/services/studio-api-client.js +2 -2
- package/dist/services/studio-api-client.js.map +1 -1
- package/dist/types/studio.d.ts +1 -7
- package/dist/types/studio.d.ts.map +1 -1
- package/dist/types/studio.js.map +1 -1
- package/dist/types.d.ts +30 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/config-loader.d.ts.map +1 -1
- package/dist/utils/config-loader.js +66 -0
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/input-parser.d.ts +30 -9
- package/dist/utils/input-parser.d.ts.map +1 -1
- package/dist/utils/input-parser.js +155 -24
- package/dist/utils/input-parser.js.map +1 -1
- package/dist/utils/studio-api.d.ts +2 -1
- package/dist/utils/studio-api.d.ts.map +1 -1
- package/dist/utils/studio-api.js +5 -36
- package/dist/utils/studio-api.js.map +1 -1
- package/package.json +12 -11
- package/dist/sembix-cli-1.5.0.tgz +0 -0
|
@@ -1,34 +1,165 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Parse workflow inputs from JSON string
|
|
3
|
-
* Supports two formats:
|
|
4
|
-
* 1. Simple key-value object: {"key": "value"} -> maps to inputVariables (deprecated)
|
|
5
|
-
* 2. InitialInstructions array: [{"id": "x", "instruction": "value"}] -> maps to initialInstructions
|
|
6
|
-
* 3. Complete StartWorkflowConfiguration object with initialInstructions or workspaceMetadata
|
|
2
|
+
* Parse workflow inputs from JSON string with automatic format detection.
|
|
7
3
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* Supports three input formats:
|
|
5
|
+
* 1. ID-based array: [{"id": "var_123", "instruction": "value"}]
|
|
6
|
+
* 2. Name-based object: {"repositoryUrl": "value"} (requires template)
|
|
7
|
+
* 3. Complete configuration: {"initialInstructions": [...], "workspaceMetadata": {...}}
|
|
8
|
+
*
|
|
9
|
+
* @param options.inputsJson - JSON string containing workflow inputs
|
|
10
|
+
* @param options.template - Template instructions (required for name-based format)
|
|
11
|
+
* @returns StartWorkflowConfiguration with initialInstructions
|
|
10
12
|
* @throws Error if JSON is invalid or format is unrecognized
|
|
11
13
|
*/
|
|
12
|
-
export function parseWorkflowInputs(
|
|
14
|
+
export function parseWorkflowInputs(options) {
|
|
15
|
+
const { inputsJson, template, validate = false } = options;
|
|
13
16
|
const parsed = JSON.parse(inputsJson);
|
|
14
|
-
|
|
17
|
+
let initialInstructions;
|
|
18
|
+
let preserveFullConfig = false;
|
|
19
|
+
let fullConfig;
|
|
20
|
+
// Format 1: Array → ID-based initialInstructions
|
|
15
21
|
if (Array.isArray(parsed)) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
initialInstructions = parsed;
|
|
23
|
+
}
|
|
24
|
+
// Validate object type before checking properties
|
|
25
|
+
else if (typeof parsed !== 'object' || parsed === null) {
|
|
26
|
+
throw new Error('Invalid input format. Expected object or array.');
|
|
27
|
+
}
|
|
28
|
+
// Format 2: Complete configuration (has config fields)
|
|
29
|
+
else if ('initialInstructions' in parsed || 'workspaceMetadata' in parsed) {
|
|
30
|
+
fullConfig = parsed;
|
|
31
|
+
initialInstructions = parsed.initialInstructions;
|
|
32
|
+
preserveFullConfig = true;
|
|
33
|
+
}
|
|
34
|
+
// Format 3: Name-based object (needs template resolution)
|
|
35
|
+
else {
|
|
36
|
+
if (!template || template.length === 0) {
|
|
37
|
+
throw new Error('Cannot resolve input variable names: name-based format requires workflow template.\n\n' +
|
|
38
|
+
'Either:\n' +
|
|
39
|
+
' 1. Use ID-based format: --inputs \'[{"id": "var_123", "instruction": "value"}]\'\n' +
|
|
40
|
+
' 2. Run interactively to see input prompts\n\n' +
|
|
41
|
+
'To see available IDs:\n' +
|
|
42
|
+
' sembix workflow template show --project-id <id> --workflow-id <id>');
|
|
26
43
|
}
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
// Resolve names to IDs
|
|
45
|
+
initialInstructions = resolveNames(parsed, template);
|
|
46
|
+
}
|
|
47
|
+
// Validate and normalize inputs if requested and template is available
|
|
48
|
+
if (validate && template && template.length > 0) {
|
|
49
|
+
initialInstructions = validateWorkflowInputs(initialInstructions, template);
|
|
50
|
+
}
|
|
51
|
+
// Build and return configuration
|
|
52
|
+
if (preserveFullConfig) {
|
|
53
|
+
// Preserve all fields from original config, update initialInstructions if present
|
|
54
|
+
if (initialInstructions) {
|
|
55
|
+
return {
|
|
56
|
+
...fullConfig,
|
|
57
|
+
initialInstructions
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return fullConfig;
|
|
61
|
+
}
|
|
62
|
+
return { initialInstructions };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Internal helper: Resolve input variable names to IDs using template.
|
|
66
|
+
*
|
|
67
|
+
* @param inputVariables - Object with input variable names as keys
|
|
68
|
+
* @param templateInstructions - Array of template instructions with id/name mappings
|
|
69
|
+
* @returns Array of InitialInstructions with resolved IDs
|
|
70
|
+
* @throws Error if input name not found in template
|
|
71
|
+
*/
|
|
72
|
+
function resolveNames(inputVariables, templateInstructions) {
|
|
73
|
+
const resolvedInstructions = [];
|
|
74
|
+
const availableNames = templateInstructions.map(t => t.name).filter(Boolean);
|
|
75
|
+
for (const [inputName, inputValue] of Object.entries(inputVariables)) {
|
|
76
|
+
// Find matching template instruction by name (case-sensitive)
|
|
77
|
+
const matchingInstruction = templateInstructions.find(t => t.name === inputName);
|
|
78
|
+
if (!matchingInstruction) {
|
|
79
|
+
throw new Error(`Input variable name "${inputName}" not found in workflow template.\n\n` +
|
|
80
|
+
`Available input variables:\n` +
|
|
81
|
+
availableNames.map(name => ` - ${name}`).join('\n') +
|
|
82
|
+
'\n\n' +
|
|
83
|
+
'To see full details:\n' +
|
|
84
|
+
' sembix workflow template show --project-id <id> --workflow-id <id>');
|
|
85
|
+
}
|
|
86
|
+
// Create a full InitialInstructions object with all fields from template
|
|
87
|
+
// and the user-provided instruction value
|
|
88
|
+
resolvedInstructions.push({
|
|
89
|
+
id: matchingInstruction.id,
|
|
90
|
+
name: matchingInstruction.name,
|
|
91
|
+
description: matchingInstruction.description,
|
|
92
|
+
instruction: inputValue,
|
|
93
|
+
dataType: matchingInstruction.dataType,
|
|
94
|
+
isRequired: matchingInstruction.isRequired
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return resolvedInstructions;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Validate workflow inputs against template requirements.
|
|
101
|
+
* Ensures required fields have values and data types are correct.
|
|
102
|
+
* Fills in optional fields with empty strings if not provided.
|
|
103
|
+
*
|
|
104
|
+
* @param instructions - Array of initial instructions to validate
|
|
105
|
+
* @param template - Template instructions with requirements
|
|
106
|
+
* @returns Validated and normalized instructions
|
|
107
|
+
* @throws Error if validation fails
|
|
108
|
+
*/
|
|
109
|
+
export function validateWorkflowInputs(instructions, template) {
|
|
110
|
+
const validated = [];
|
|
111
|
+
const errors = [];
|
|
112
|
+
// Create map of provided instructions by ID
|
|
113
|
+
const providedMap = new Map(instructions.map(i => [i.id, i]));
|
|
114
|
+
// Iterate through template to validate all fields
|
|
115
|
+
for (const templateInstr of template) {
|
|
116
|
+
const provided = providedMap.get(templateInstr.id);
|
|
117
|
+
const value = provided?.instruction;
|
|
118
|
+
// Validate required fields
|
|
119
|
+
if (templateInstr.isRequired) {
|
|
120
|
+
if (value === undefined || value === null || value === '') {
|
|
121
|
+
errors.push(`Required input "${templateInstr.name}" is missing or empty`);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
// Validate boolean fields
|
|
125
|
+
if (templateInstr.dataType === 'boolean') {
|
|
126
|
+
if (typeof value === 'boolean') {
|
|
127
|
+
// Convert boolean to string for API
|
|
128
|
+
validated.push({
|
|
129
|
+
...templateInstr,
|
|
130
|
+
instruction: String(value)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else if (value === 'true' || value === 'false') {
|
|
134
|
+
validated.push({
|
|
135
|
+
...templateInstr,
|
|
136
|
+
instruction: value
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
errors.push(`Input "${templateInstr.name}" must be true or false (got: ${value})`);
|
|
141
|
+
}
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Handle optional fields - always include with empty string if not provided
|
|
146
|
+
if (!templateInstr.isRequired && (value === undefined || value === null)) {
|
|
147
|
+
validated.push({
|
|
148
|
+
...templateInstr,
|
|
149
|
+
instruction: ''
|
|
150
|
+
});
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
// For provided values, pass through with template metadata
|
|
154
|
+
validated.push({
|
|
155
|
+
...templateInstr,
|
|
156
|
+
instruction: value !== undefined ? value : ''
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (errors.length > 0) {
|
|
160
|
+
throw new Error('Input validation failed:\n' +
|
|
161
|
+
errors.map(e => ` - ${e}`).join('\n'));
|
|
31
162
|
}
|
|
32
|
-
|
|
163
|
+
return validated;
|
|
33
164
|
}
|
|
34
165
|
//# sourceMappingURL=input-parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-parser.js","sourceRoot":"","sources":["../../src/utils/input-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"input-parser.js","sourceRoot":"","sources":["../../src/utils/input-parser.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAmC;IACrE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAEtC,IAAI,mBAA0C,CAAC;IAC/C,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAC/B,IAAI,UAAe,CAAC;IAEpB,iDAAiD;IACjD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,mBAAmB,GAAG,MAAM,CAAC;IAC/B,CAAC;IACD,kDAAkD;SAC7C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CA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AI,CAAC;YACb,GAAG,aAAa;YAChB,WAAW,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;SAC9C,CAAC,CAAC;IACL,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,4BAA4B;YAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACvC,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -6,7 +6,8 @@ import type { StudioProfile, StudioAuthTokens, StartWorkflowConfiguration, Workf
|
|
|
6
6
|
* This factory function:
|
|
7
7
|
* 1. Loads the specified profile (or default) and validates authentication
|
|
8
8
|
* 2. Creates a StudioApiClient instance
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
|
+
* Note: The StudioApiClient already handles token refresh on 401 errors internally.
|
|
10
11
|
*
|
|
11
12
|
* @param profileName - Optional profile name (defaults to active profile)
|
|
12
13
|
* @returns StudioApiClient instance with token refresh capability
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio-api.d.ts","sourceRoot":"","sources":["../../src/utils/studio-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"studio-api.d.ts","sourceRoot":"","sources":["../../src/utils/studio-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAMnE,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,YAAY,EACb,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAK1F;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,0BAA0B,EAC9C,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAGhC;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,wBAAwB,CAAC,CAGnC;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,YAAY,EACpB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,wBAAwB,CAAC,CAGnC;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAGf;AAGD,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,YAAY,EACb,CAAC"}
|
package/dist/utils/studio-api.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// Service layer imports
|
|
2
2
|
import { StudioApiClient } from '../services/studio-api-client.js';
|
|
3
|
-
import { CognitoAuthService } from '../services/cognito-auth.js';
|
|
4
3
|
// Utility imports
|
|
5
|
-
import { getAuthenticatedProfile
|
|
4
|
+
import { getAuthenticatedProfile } from './studio-config.js';
|
|
6
5
|
/**
|
|
7
6
|
* Creates a Studio API client with automatic token refresh handling.
|
|
8
7
|
*
|
|
9
8
|
* This factory function:
|
|
10
9
|
* 1. Loads the specified profile (or default) and validates authentication
|
|
11
10
|
* 2. Creates a StudioApiClient instance
|
|
12
|
-
*
|
|
11
|
+
*
|
|
12
|
+
* Note: The StudioApiClient already handles token refresh on 401 errors internally.
|
|
13
13
|
*
|
|
14
14
|
* @param profileName - Optional profile name (defaults to active profile)
|
|
15
15
|
* @returns StudioApiClient instance with token refresh capability
|
|
@@ -17,39 +17,8 @@ import { getAuthenticatedProfile, saveTokens } from './studio-config.js';
|
|
|
17
17
|
*/
|
|
18
18
|
export async function createStudioApiClient(profileName) {
|
|
19
19
|
const { profile, tokens } = await getAuthenticatedProfile(profileName);
|
|
20
|
-
// Create
|
|
21
|
-
|
|
22
|
-
// Wrap client methods to handle token refresh on 401
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
const originalRequest = client._makeRequest.bind(client);
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
-
client._makeRequest = async function (method, path, body, queryParams) {
|
|
27
|
-
try {
|
|
28
|
-
return await originalRequest(method, path, body, queryParams);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
// If 401 error, attempt token refresh and retry
|
|
32
|
-
const errorWithStatus = error;
|
|
33
|
-
if (errorWithStatus.statusCode === 401) {
|
|
34
|
-
try {
|
|
35
|
-
const authService = new CognitoAuthService(profile);
|
|
36
|
-
const newTokens = await authService.refreshTokens(tokens.refreshToken);
|
|
37
|
-
// Save refreshed tokens
|
|
38
|
-
await saveTokens(profile.name, newTokens);
|
|
39
|
-
// Update client tokens
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
-
client.tokens = newTokens;
|
|
42
|
-
// Retry original request with new tokens
|
|
43
|
-
return await originalRequest(method, path, body, queryParams);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
throw new Error(`Authentication failed and token refresh unsuccessful. Run "sembix login --profile ${profile.name}" to re-authenticate.`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
return client;
|
|
20
|
+
// Create and return client - it already handles token refresh internally
|
|
21
|
+
return new StudioApiClient(profile, tokens);
|
|
53
22
|
}
|
|
54
23
|
/**
|
|
55
24
|
* Convenience function to start a workflow execution.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio-api.js","sourceRoot":"","sources":["../../src/utils/studio-api.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"studio-api.js","sourceRoot":"","sources":["../../src/utils/studio-api.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,kBAAkB;AAClB,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAa7D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,WAAoB;IAC9D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAEvE,yEAAyE;IACzE,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,SAAiB,EACjB,UAAkB,EAClB,kBAA8C,EAC9C,WAAoB;IAEpB,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,WAAW,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAAkB,EAClB,KAAa,EACb,WAAoB;IAEpB,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,WAAW,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAoB,EACpB,WAAoB;IAEpB,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,WAAW,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAAiB,EACjB,UAAkB,EAClB,KAAa,EACb,WAAoB;IAEpB,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,WAAW,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AAC9D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sembix/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "CLI tool for managing Sembix products",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@inquirer/prompts": "^8.0.
|
|
59
|
+
"@inquirer/prompts": "^8.0.2",
|
|
60
60
|
"@octokit/rest": "^22.0.1",
|
|
61
61
|
"chalk": "^5.6.2",
|
|
62
62
|
"commander": "^14.0.2",
|
|
@@ -64,7 +64,8 @@
|
|
|
64
64
|
"js-yaml": "^4.1.1",
|
|
65
65
|
"libsodium-wrappers": "^0.7.15",
|
|
66
66
|
"ora": "^9.0.0",
|
|
67
|
-
"zod": "^4.1.
|
|
67
|
+
"zod": "^4.1.13",
|
|
68
|
+
"glob": "11.1.0"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@semantic-release/changelog": "^6.0.3",
|
|
@@ -76,17 +77,17 @@
|
|
|
76
77
|
"@types/js-yaml": "^4.0.9",
|
|
77
78
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
78
79
|
"@types/libsodium-wrappers": "^0.7.14",
|
|
79
|
-
"@types/node": "^24.10.
|
|
80
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
81
|
-
"@typescript-eslint/parser": "^8.
|
|
82
|
-
"@vitest/coverage-v8": "^4.0.
|
|
83
|
-
"@vitest/ui": "^4.0.
|
|
80
|
+
"@types/node": "^24.10.3",
|
|
81
|
+
"@typescript-eslint/eslint-plugin": "^8.49.0",
|
|
82
|
+
"@typescript-eslint/parser": "^8.49.0",
|
|
83
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
84
|
+
"@vitest/ui": "^4.0.15",
|
|
84
85
|
"eslint": "^9.39.1",
|
|
85
|
-
"happy-dom": "^20.0.
|
|
86
|
+
"happy-dom": "^20.0.11",
|
|
86
87
|
"semantic-release": "^25.0.2",
|
|
87
|
-
"tsx": "^4.
|
|
88
|
+
"tsx": "^4.21.0",
|
|
88
89
|
"typescript": "^5.9.3",
|
|
89
|
-
"vitest": "^4.0.
|
|
90
|
+
"vitest": "^4.0.15"
|
|
90
91
|
},
|
|
91
92
|
"engines": {
|
|
92
93
|
"node": ">=20.0.0"
|
|
Binary file
|