@sembix/cli 1.0.2 → 1.2.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.
Files changed (42) hide show
  1. package/.env.example +7 -0
  2. package/README.md +161 -8
  3. package/dist/__tests__/config.test.d.ts +2 -0
  4. package/dist/__tests__/config.test.d.ts.map +1 -0
  5. package/dist/__tests__/config.test.js +75 -0
  6. package/dist/__tests__/config.test.js.map +1 -0
  7. package/dist/__tests__/integration/configure.test.d.ts +2 -0
  8. package/dist/__tests__/integration/configure.test.d.ts.map +1 -0
  9. package/dist/__tests__/integration/configure.test.js +247 -0
  10. package/dist/__tests__/integration/configure.test.js.map +1 -0
  11. package/dist/commands/__tests__/configure.test.d.ts +2 -0
  12. package/dist/commands/__tests__/configure.test.d.ts.map +1 -0
  13. package/dist/commands/__tests__/configure.test.js +229 -0
  14. package/dist/commands/__tests__/configure.test.js.map +1 -0
  15. package/dist/commands/configure.d.ts +6 -0
  16. package/dist/commands/configure.d.ts.map +1 -0
  17. package/dist/commands/configure.js +90 -0
  18. package/dist/commands/configure.js.map +1 -0
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/config.js +19 -3
  21. package/dist/config.js.map +1 -1
  22. package/dist/index.js +25 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/prompts/__tests__/environment-setup.test.d.ts +2 -0
  25. package/dist/prompts/__tests__/environment-setup.test.d.ts.map +1 -0
  26. package/dist/prompts/__tests__/environment-setup.test.js +206 -0
  27. package/dist/prompts/__tests__/environment-setup.test.js.map +1 -0
  28. package/dist/prompts/__tests__/hub-integration.test.d.ts +2 -0
  29. package/dist/prompts/__tests__/hub-integration.test.d.ts.map +1 -0
  30. package/dist/prompts/__tests__/hub-integration.test.js +126 -0
  31. package/dist/prompts/__tests__/hub-integration.test.js.map +1 -0
  32. package/dist/sembix-cli-1.2.0.tgz +0 -0
  33. package/dist/utils/__tests__/config-file.test.d.ts +2 -0
  34. package/dist/utils/__tests__/config-file.test.d.ts.map +1 -0
  35. package/dist/utils/__tests__/config-file.test.js +218 -0
  36. package/dist/utils/__tests__/config-file.test.js.map +1 -0
  37. package/dist/utils/config-file.d.ts +23 -0
  38. package/dist/utils/config-file.d.ts.map +1 -0
  39. package/dist/utils/config-file.js +100 -0
  40. package/dist/utils/config-file.js.map +1 -0
  41. package/package.json +1 -1
  42. package/dist/sembix-cli-1.0.2.tgz +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-file.d.ts","sourceRoot":"","sources":["../../src/utils/config-file.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAWD;;;GAGG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,YAAY,CAAC,CAaxD;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAOrE;AAwDD;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
@@ -0,0 +1,100 @@
1
+ import { homedir } from 'os';
2
+ import { join } from 'path';
3
+ import { promises as fs } from 'fs';
4
+ import { existsSync } from 'fs';
5
+ const CONFIG_DIR = join(homedir(), '.sembix');
6
+ const CONFIG_FILE = join(CONFIG_DIR, 'config');
7
+ /**
8
+ * Ensures the ~/.sembix directory exists with proper permissions
9
+ */
10
+ async function ensureConfigDirectory() {
11
+ if (!existsSync(CONFIG_DIR)) {
12
+ await fs.mkdir(CONFIG_DIR, { recursive: true, mode: 0o700 });
13
+ }
14
+ }
15
+ /**
16
+ * Reads the configuration from ~/.sembix/config
17
+ * Returns an empty object if the file doesn't exist
18
+ */
19
+ export async function readConfig() {
20
+ try {
21
+ if (!existsSync(CONFIG_FILE)) {
22
+ return {};
23
+ }
24
+ const content = await fs.readFile(CONFIG_FILE, 'utf-8');
25
+ return parseConfig(content);
26
+ }
27
+ catch {
28
+ // If we can't read the config, return empty object
29
+ // This allows the app to fall back to other config sources
30
+ return {};
31
+ }
32
+ }
33
+ /**
34
+ * Writes configuration to ~/.sembix/config
35
+ * Creates the directory if it doesn't exist
36
+ */
37
+ export async function writeConfig(config) {
38
+ await ensureConfigDirectory();
39
+ const content = formatConfig(config);
40
+ // Write with restricted permissions (only user can read/write)
41
+ await fs.writeFile(CONFIG_FILE, content, { mode: 0o600 });
42
+ }
43
+ /**
44
+ * Parses INI-style config content into a SembixConfig object
45
+ */
46
+ function parseConfig(content) {
47
+ const config = {};
48
+ const lines = content.split('\n');
49
+ for (const line of lines) {
50
+ const trimmed = line.trim();
51
+ // Skip empty lines and comments
52
+ if (!trimmed || trimmed.startsWith('#') || trimmed.startsWith(';')) {
53
+ continue;
54
+ }
55
+ // Parse key=value pairs
56
+ const match = trimmed.match(/^([^=]+)=(.*)$/);
57
+ if (match) {
58
+ const key = match[1].trim();
59
+ const value = match[2].trim();
60
+ if (key === 'github_token') {
61
+ config.github_token = value;
62
+ }
63
+ else if (key === 'default_github_org') {
64
+ config.default_github_org = value;
65
+ }
66
+ }
67
+ }
68
+ return config;
69
+ }
70
+ /**
71
+ * Formats a SembixConfig object into INI-style content
72
+ */
73
+ function formatConfig(config) {
74
+ const lines = [
75
+ '# Sembix CLI Configuration',
76
+ '# Generated by: sembix configure',
77
+ '',
78
+ ];
79
+ if (config.github_token) {
80
+ lines.push(`github_token=${config.github_token}`);
81
+ }
82
+ if (config.default_github_org) {
83
+ lines.push(`default_github_org=${config.default_github_org}`);
84
+ }
85
+ lines.push(''); // trailing newline
86
+ return lines.join('\n');
87
+ }
88
+ /**
89
+ * Returns the path to the config file for display purposes
90
+ */
91
+ export function getConfigPath() {
92
+ return CONFIG_FILE;
93
+ }
94
+ /**
95
+ * Checks if the config file exists
96
+ */
97
+ export function configExists() {
98
+ return existsSync(CONFIG_FILE);
99
+ }
100
+ //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AAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,sBAAsB,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sembix/cli",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "CLI tool for managing Sembix products",
5
5
  "type": "module",
6
6
  "bin": {
Binary file