@7nsane/zift 1.0.7 → 1.0.8
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/zift.js +16 -10
- package/package.json +1 -1
package/bin/zift.js
CHANGED
|
@@ -13,13 +13,11 @@ async function main() {
|
|
|
13
13
|
let format = 'text';
|
|
14
14
|
let isInstallMode = false;
|
|
15
15
|
|
|
16
|
-
// 1. Setup Command
|
|
17
16
|
if (args[0] === 'setup') {
|
|
18
17
|
await runSetup();
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
// 2. Installation Verbs
|
|
23
21
|
if (args[0] === 'install' || args[0] === 'i') {
|
|
24
22
|
isInstallMode = true;
|
|
25
23
|
target = args.find((a, i) => i > 0 && !a.startsWith('-')) || '.';
|
|
@@ -30,7 +28,6 @@ async function main() {
|
|
|
30
28
|
target = args.find(a => !a.startsWith('-') && !['install', 'i', 'npm'].includes(a)) || '.';
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
// 3. Flags
|
|
34
31
|
for (let i = 0; i < args.length; i++) {
|
|
35
32
|
if (args[i] === '--format' && args[i + 1]) {
|
|
36
33
|
format = args[i + 1];
|
|
@@ -38,13 +35,11 @@ async function main() {
|
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
// 4. No Args? Show Help
|
|
42
38
|
if (args.length === 0) {
|
|
43
39
|
showHelp();
|
|
44
40
|
return;
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
// 5. Execution
|
|
48
43
|
const isLocal = fs.existsSync(target) && fs.lstatSync(target).isDirectory();
|
|
49
44
|
|
|
50
45
|
if (isLocal) {
|
|
@@ -65,13 +60,16 @@ async function runSetup() {
|
|
|
65
60
|
rl.close();
|
|
66
61
|
if (['y', 'yes'].includes(answer.toLowerCase())) {
|
|
67
62
|
try {
|
|
63
|
+
let reloadCmd = '';
|
|
68
64
|
if (os.platform() === 'win32') {
|
|
69
|
-
setupWindows();
|
|
65
|
+
reloadCmd = setupWindows();
|
|
70
66
|
} else {
|
|
71
|
-
setupUnix();
|
|
67
|
+
reloadCmd = setupUnix();
|
|
72
68
|
}
|
|
73
|
-
console.log(chalk.green('\n✅ Setup complete!
|
|
74
|
-
console.log(chalk.
|
|
69
|
+
console.log(chalk.green('\n✅ Setup complete! Profile updated.'));
|
|
70
|
+
console.log(chalk.yellow.bold(`\nTo activate IMMEDIATELY, run this command:`));
|
|
71
|
+
console.log(chalk.cyan.inverse(` ${reloadCmd} \n`));
|
|
72
|
+
console.log(chalk.gray('Alternatively, simply restart your terminal.'));
|
|
75
73
|
} catch (e) {
|
|
76
74
|
console.error(chalk.red('\n❌ Setup failed: ') + e.message);
|
|
77
75
|
}
|
|
@@ -98,6 +96,7 @@ function npm {
|
|
|
98
96
|
const profileDir = path.dirname(profilePath);
|
|
99
97
|
if (!fs.existsSync(profileDir)) fs.mkdirSync(profileDir, { recursive: true });
|
|
100
98
|
fs.appendFileSync(profilePath, psFunction);
|
|
99
|
+
return '. $PROFILE';
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
function setupUnix() {
|
|
@@ -114,7 +113,14 @@ npm() {
|
|
|
114
113
|
`;
|
|
115
114
|
const home = os.homedir();
|
|
116
115
|
const profiles = [path.join(home, '.bashrc'), path.join(home, '.zshrc')];
|
|
117
|
-
|
|
116
|
+
let reloadTarget = '~/.zshrc';
|
|
117
|
+
profiles.forEach(p => {
|
|
118
|
+
if (fs.existsSync(p)) {
|
|
119
|
+
fs.appendFileSync(p, bashFunction);
|
|
120
|
+
if (p.endsWith('.bashrc')) reloadTarget = '~/.bashrc';
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return `source ${reloadTarget}`;
|
|
118
124
|
}
|
|
119
125
|
|
|
120
126
|
async function runLocalScan(targetDir, format) {
|