aka-cli 1.0.13
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 +95 -0
- package/bin/.gitkeep +1 -0
- package/bin/aka +0 -0
- package/index.js +11 -0
- package/package.json +44 -0
- package/scripts/postinstall.js +139 -0
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# aka
|
|
2
|
+
|
|
3
|
+
A simple alias manager that lets you add, list, and apply command aliases.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Using curl (recommended)
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
curl -fsSL https://raw.githubusercontent.com/fdorantesm/aka/refs/heads/main/install.sh | bash
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Using npm
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install -g aka-cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Using yarn
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
yarn global add aka-cli
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Using pnpm
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
pnpm add -g aka-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Using bun
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
bun add -g aka-cli
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Using deno
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
deno install -A -n aka npm:aka-cli
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Using npmx.dev
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npmx aka-cli
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
### Help
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
aka [command]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Add alias
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
aka add ll "ls -la"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### List
|
|
64
|
+
|
|
65
|
+
List all aliases:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
aka list
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Filter aliases with glob patterns:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
aka list '*dev*' # Aliases containing "dev"
|
|
75
|
+
aka list 'aws*' # Aliases starting with "aws"
|
|
76
|
+
aka list '*-qa' # Aliases ending with "-qa"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Remove alias
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
aka remove ll
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Export aliases
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
aka export aliases.json
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Import aliases
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
aka import aliases.json
|
|
95
|
+
```
|
package/bin/.gitkeep
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# This directory will contain the aka binary after installation
|
package/bin/aka
ADDED
|
Binary file
|
package/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// This package provides a binary CLI tool.
|
|
4
|
+
// Use: aka [command]
|
|
5
|
+
// Run: aka --help for more information
|
|
6
|
+
|
|
7
|
+
console.error(
|
|
8
|
+
'Please use the "aka" command directly instead of requiring this module.',
|
|
9
|
+
);
|
|
10
|
+
console.error("Run: aka --help for more information.");
|
|
11
|
+
process.exit(1);
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aka-cli",
|
|
3
|
+
"version": "1.0.13",
|
|
4
|
+
"description": "A simple alias manager that lets you add, list, and apply command aliases",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"aka": "./bin/aka"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node scripts/postinstall.js"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"alias",
|
|
14
|
+
"cli",
|
|
15
|
+
"command-line",
|
|
16
|
+
"productivity",
|
|
17
|
+
"aliases",
|
|
18
|
+
"shell",
|
|
19
|
+
"bash",
|
|
20
|
+
"zsh"
|
|
21
|
+
],
|
|
22
|
+
"author": "Fernando Dorantes",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/fdorantesm/aka.git"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/fdorantesm/aka#readme",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/fdorantesm/aka/issues"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"bin/",
|
|
34
|
+
"scripts/",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"os": [
|
|
38
|
+
"darwin",
|
|
39
|
+
"linux"
|
|
40
|
+
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=14"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const https = require('https');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const GITHUB_REPO = 'fdorantesm/aka';
|
|
8
|
+
const BIN_DIR = path.join(__dirname, '..', 'bin');
|
|
9
|
+
const BINARY_NAME = 'aka';
|
|
10
|
+
|
|
11
|
+
// Ensure bin directory exists
|
|
12
|
+
if (!fs.existsSync(BIN_DIR)) {
|
|
13
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getPlatformInfo() {
|
|
17
|
+
const platform = process.platform;
|
|
18
|
+
const arch = process.arch;
|
|
19
|
+
|
|
20
|
+
let binaryName;
|
|
21
|
+
|
|
22
|
+
if (platform === 'darwin') {
|
|
23
|
+
binaryName = 'aka-darwin';
|
|
24
|
+
} else if (platform === 'linux') {
|
|
25
|
+
binaryName = 'aka-linux';
|
|
26
|
+
} else {
|
|
27
|
+
throw new Error(`Unsupported platform: ${platform} ${arch}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return { binaryName };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getLatestRelease() {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const options = {
|
|
36
|
+
hostname: 'api.github.com',
|
|
37
|
+
path: `/repos/${GITHUB_REPO}/releases/latest`,
|
|
38
|
+
headers: {
|
|
39
|
+
'User-Agent': 'aka-npm-installer'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
https.get(options, (res) => {
|
|
44
|
+
let data = '';
|
|
45
|
+
|
|
46
|
+
res.on('data', (chunk) => {
|
|
47
|
+
data += chunk;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
res.on('end', () => {
|
|
51
|
+
try {
|
|
52
|
+
const release = JSON.parse(data);
|
|
53
|
+
resolve(release);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
reject(new Error(`Failed to parse release data: ${error.message}`));
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}).on('error', (error) => {
|
|
59
|
+
reject(new Error(`Failed to fetch latest release: ${error.message}`));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function downloadFile(url, destination) {
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
const file = fs.createWriteStream(destination);
|
|
67
|
+
|
|
68
|
+
https.get(url, {
|
|
69
|
+
headers: {
|
|
70
|
+
'User-Agent': 'aka-npm-installer'
|
|
71
|
+
}
|
|
72
|
+
}, (response) => {
|
|
73
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
74
|
+
// Follow redirect
|
|
75
|
+
downloadFile(response.headers.location, destination)
|
|
76
|
+
.then(resolve)
|
|
77
|
+
.catch(reject);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (response.statusCode !== 200) {
|
|
82
|
+
reject(new Error(`Failed to download: ${response.statusCode}`));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
response.pipe(file);
|
|
87
|
+
|
|
88
|
+
file.on('finish', () => {
|
|
89
|
+
file.close();
|
|
90
|
+
resolve();
|
|
91
|
+
});
|
|
92
|
+
}).on('error', (error) => {
|
|
93
|
+
fs.unlink(destination, () => {});
|
|
94
|
+
reject(new Error(`Download failed: ${error.message}`));
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
file.on('error', (error) => {
|
|
98
|
+
fs.unlink(destination, () => {});
|
|
99
|
+
reject(new Error(`File write failed: ${error.message}`));
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function install() {
|
|
105
|
+
try {
|
|
106
|
+
console.log('📦 Installing aka...');
|
|
107
|
+
|
|
108
|
+
const { binaryName } = getPlatformInfo();
|
|
109
|
+
console.log(`🔍 Detected platform binary: ${binaryName}`);
|
|
110
|
+
|
|
111
|
+
console.log('🌐 Fetching latest release...');
|
|
112
|
+
const release = await getLatestRelease();
|
|
113
|
+
const version = release.tag_name;
|
|
114
|
+
console.log(`✨ Latest version: ${version}`);
|
|
115
|
+
|
|
116
|
+
const asset = release.assets.find(asset => asset.name === binaryName);
|
|
117
|
+
if (!asset) {
|
|
118
|
+
throw new Error(`Binary ${binaryName} not found in release ${version}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const downloadUrl = asset.browser_download_url;
|
|
122
|
+
const binaryPath = path.join(BIN_DIR, BINARY_NAME);
|
|
123
|
+
|
|
124
|
+
console.log(`⬇️ Downloading from ${downloadUrl}...`);
|
|
125
|
+
await downloadFile(downloadUrl, binaryPath);
|
|
126
|
+
|
|
127
|
+
// Make binary executable
|
|
128
|
+
fs.chmodSync(binaryPath, '755');
|
|
129
|
+
|
|
130
|
+
console.log('✅ aka installed successfully!');
|
|
131
|
+
console.log('');
|
|
132
|
+
console.log('Run "aka --help" to get started.');
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error('❌ Installation failed:', error.message);
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
install();
|