uai-direct 1.0.0 ā 1.0.1
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/bin/cli.js +75 -34
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -25,6 +25,28 @@ const PRESET_COLORS = {
|
|
|
25
25
|
red: { primary: '#dc2626', secondary: '#ef4444' }
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
function copyDirRecursive(src, dest) {
|
|
29
|
+
if (!fs.existsSync(dest)) {
|
|
30
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
33
|
+
|
|
34
|
+
for (const entry of entries) {
|
|
35
|
+
const srcPath = path.join(src, entry.name);
|
|
36
|
+
const destPath = path.join(dest, entry.name);
|
|
37
|
+
|
|
38
|
+
if (entry.name === 'node_modules' || entry.name === '.git' || entry.name === 'dist') {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (entry.isDirectory()) {
|
|
43
|
+
copyDirRecursive(srcPath, destPath);
|
|
44
|
+
} else {
|
|
45
|
+
fs.copyFileSync(srcPath, destPath);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
28
50
|
async function main() {
|
|
29
51
|
console.log('\n====================================================');
|
|
30
52
|
console.log(' UAI-DIRECT - Platform Setup Wizard ');
|
|
@@ -48,41 +70,51 @@ async function main() {
|
|
|
48
70
|
const letters = platformName.split('');
|
|
49
71
|
|
|
50
72
|
// Prompt 2: Fullform / Acronym Check
|
|
51
|
-
const
|
|
52
|
-
const
|
|
73
|
+
const fullformAnswer = await askQuestion(`\nDo you have a fullform/acronym for ${platformName}? (Enter phrase or y/N): `);
|
|
74
|
+
const trimmedAnswer = fullformAnswer.trim();
|
|
53
75
|
|
|
54
76
|
let fullFormPhrase = '';
|
|
55
|
-
let sequenceSteps = [];
|
|
56
77
|
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const firstChar = cleanWord.charAt(0).toUpperCase();
|
|
76
|
-
|
|
77
|
-
if (letterIndex < letters.length && firstChar === letters[letterIndex]) {
|
|
78
|
-
const currentHighlight = letterIndex;
|
|
79
|
-
letterIndex++;
|
|
80
|
-
return { highlightIndex: currentHighlight, word };
|
|
81
|
-
} else {
|
|
82
|
-
return { highlightIndex: null, word };
|
|
83
|
-
}
|
|
84
|
-
});
|
|
78
|
+
if (trimmedAnswer) {
|
|
79
|
+
const lower = trimmedAnswer.toLowerCase();
|
|
80
|
+
if (lower === 'n' || lower === 'no') {
|
|
81
|
+
fullFormPhrase = '';
|
|
82
|
+
} else if (lower === 'y' || lower === 'yes') {
|
|
83
|
+
const defaultPhrase = platformName === 'SAMPARK'
|
|
84
|
+
? 'Single Administrative Management Portal for Access, Resources and Knowledge'
|
|
85
|
+
: '';
|
|
86
|
+
|
|
87
|
+
const phrasePrompt = defaultPhrase
|
|
88
|
+
? `Enter fullform phrase [default: '${defaultPhrase}']: `
|
|
89
|
+
: `Enter fullform phrase for ${platformName}: `;
|
|
90
|
+
|
|
91
|
+
const inputPhrase = await askQuestion(phrasePrompt);
|
|
92
|
+
fullFormPhrase = inputPhrase.trim() || defaultPhrase;
|
|
93
|
+
} else {
|
|
94
|
+
// User directly pasted/typed the fullform phrase in the prompt!
|
|
95
|
+
fullFormPhrase = trimmedAnswer;
|
|
85
96
|
}
|
|
97
|
+
} else if (platformName === 'SAMPARK') {
|
|
98
|
+
fullFormPhrase = 'Single Administrative Management Portal for Access, Resources and Knowledge';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let sequenceSteps = [];
|
|
102
|
+
if (fullFormPhrase) {
|
|
103
|
+
const words = fullFormPhrase.split(/\s+/);
|
|
104
|
+
let letterIndex = 0;
|
|
105
|
+
|
|
106
|
+
sequenceSteps = words.map((word) => {
|
|
107
|
+
const cleanWord = word.replace(/[^a-zA-Z0-9]/g, '');
|
|
108
|
+
const firstChar = cleanWord.charAt(0).toUpperCase();
|
|
109
|
+
|
|
110
|
+
if (letterIndex < letters.length && firstChar === letters[letterIndex]) {
|
|
111
|
+
const currentHighlight = letterIndex;
|
|
112
|
+
letterIndex++;
|
|
113
|
+
return { highlightIndex: currentHighlight, word };
|
|
114
|
+
} else {
|
|
115
|
+
return { highlightIndex: null, word };
|
|
116
|
+
}
|
|
117
|
+
});
|
|
86
118
|
}
|
|
87
119
|
|
|
88
120
|
// Fallback sequence steps if no fullform supplied
|
|
@@ -121,11 +153,19 @@ async function main() {
|
|
|
121
153
|
sequenceSteps
|
|
122
154
|
};
|
|
123
155
|
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
156
|
+
const currentDir = process.cwd();
|
|
157
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
158
|
+
|
|
159
|
+
// If current working directory is missing package.json, scaffold project template
|
|
160
|
+
if (!fs.existsSync(path.join(currentDir, 'package.json')) || !fs.existsSync(path.join(currentDir, 'src'))) {
|
|
161
|
+
console.log('\nš¦ Scaffolding UAI Host Project files into target folder...');
|
|
162
|
+
copyDirRecursive(packageRoot, currentDir);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const targetConfigPath = path.join(currentDir, 'src', 'uai.config.json');
|
|
127
166
|
|
|
128
167
|
try {
|
|
168
|
+
fs.mkdirSync(path.join(currentDir, 'src'), { recursive: true });
|
|
129
169
|
fs.writeFileSync(targetConfigPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
130
170
|
console.log('\n====================================================');
|
|
131
171
|
console.log(`ā Successfully configured platform: ${platformName}`);
|
|
@@ -134,6 +174,7 @@ async function main() {
|
|
|
134
174
|
console.log(`ā Configuration saved to: src/uai.config.json`);
|
|
135
175
|
console.log('====================================================\n');
|
|
136
176
|
console.log('Next steps:');
|
|
177
|
+
console.log(' npm install # Install dependencies (if not installed)');
|
|
137
178
|
console.log(' npm run dev # Launch local preview server');
|
|
138
179
|
console.log(' npm run build # Compile for production deployment\n');
|
|
139
180
|
} catch (err) {
|