@ngocsangairvds/vsaf 4.1.11 → 4.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngocsangairvds/vsaf",
3
- "version": "4.1.11",
3
+ "version": "4.1.12",
4
4
  "description": "logging step",
5
5
  "main": "packages/core/dist/index.js",
6
6
  "types": "packages/core/dist/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  import { execSync } from 'child_process';
20
- import { existsSync, cpSync, mkdirSync, writeFileSync, rmSync } from 'fs';
20
+ import { existsSync, cpSync, mkdirSync, writeFileSync, rmSync, readFileSync } from 'fs';
21
21
  import { join } from 'path';
22
22
  import { homedir } from 'os';
23
23
 
@@ -220,14 +220,51 @@ VDS_GIT_CONCURRENCY_DEFAULT=8
220
220
  `;
221
221
 
222
222
  function provisionEnv() {
223
- if (existsSync(ENV_FILE)) {
224
- log('⊘', `.env already exists at ${ENV_FILE}`);
223
+ mkdirSync(ENV_DIR, { recursive: true });
224
+
225
+ if (!existsSync(ENV_FILE)) {
226
+ writeFileSync(ENV_FILE, ENV_TEMPLATE, 'utf-8');
227
+ log('✓', `.env template created at ${ENV_FILE}`);
228
+ log('⚠', `Fill in your credentials: ${ENV_FILE}`);
225
229
  return;
226
230
  }
227
- mkdirSync(ENV_DIR, { recursive: true });
228
- writeFileSync(ENV_FILE, ENV_TEMPLATE, 'utf-8');
229
- log('✓', `.env template created at ${ENV_FILE}`);
230
- log('', `Fill in your credentials: ${ENV_FILE}`);
231
+
232
+ if (force) {
233
+ writeFileSync(ENV_FILE, ENV_TEMPLATE, 'utf-8');
234
+ log('', `.env overwritten at ${ENV_FILE}`);
235
+ log('⚠', `Fill in your credentials: ${ENV_FILE}`);
236
+ return;
237
+ }
238
+
239
+ // Merge: add missing variables from template into existing .env
240
+ const existing = readFileSync(ENV_FILE, 'utf-8');
241
+ const existingKeys = new Set(
242
+ existing.split('\n')
243
+ .map(line => line.trim())
244
+ .filter(line => line && !line.startsWith('#'))
245
+ .map(line => line.split('=')[0].trim()),
246
+ );
247
+
248
+ const newLines = [];
249
+ for (const line of ENV_TEMPLATE.split('\n')) {
250
+ const trimmed = line.trim();
251
+ if (!trimmed || trimmed.startsWith('#')) continue;
252
+ const key = trimmed.split('=')[0].trim();
253
+ if (!existingKeys.has(key)) {
254
+ newLines.push(line);
255
+ }
256
+ }
257
+
258
+ if (newLines.length > 0) {
259
+ const append = '\n# ── Added by vds-skill installer ──\n' + newLines.join('\n') + '\n';
260
+ writeFileSync(ENV_FILE, existing.trimEnd() + '\n' + append, 'utf-8');
261
+ log('✓', `${newLines.length} new variable(s) added to ${ENV_FILE}`);
262
+ for (const line of newLines) {
263
+ log(' +', line.split('=')[0]);
264
+ }
265
+ } else {
266
+ log('⊘', `.env already up-to-date at ${ENV_FILE}`);
267
+ }
231
268
  }
232
269
 
233
270
  // ── Main ──