Skip to content

Commit d73da35

Browse files
committed
add npm release
1 parent b2ecec6 commit d73da35

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ vendor/
2323
giter
2424
dist/
2525
bin/
26+
node_modules/
27+
package-lock.json

cli/giter.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
const path = require('path');
5+
const cp = require('child_process');
6+
7+
const binPath = path.join(__dirname, '../bin/giter');
8+
9+
cp.spawn(binPath, process.argv.slice(2), {
10+
cwd: process.cwd(),
11+
stdio: ['inherit', 'inherit', 'inherit']
12+
});

cli/install.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const download = require('download');
2+
const ora = require('ora');
3+
const pkg = require('../package.json');
4+
5+
const PLATFORM = {
6+
'darwin': 'darwin',
7+
'freebsd': 'freebsd',
8+
'linux': 'linux',
9+
'openbsd': 'openbsd',
10+
'win32': 'windows'
11+
};
12+
const ARCH = {
13+
'ia32': '386',
14+
'x64': 'amd64',
15+
'x32': '386'
16+
};
17+
18+
function install() {
19+
if (!(process.arch in ARCH)) {
20+
console.error('Installation is not supported for this architecture: ' + process.arch);
21+
return;
22+
}
23+
24+
if (!(process.platform in PLATFORM)) {
25+
console.error('Installation is not supported for this platform: ' + process.platform);
26+
return;
27+
}
28+
const platform = PLATFORM[process.platform];
29+
const arch = ARCH[process.arch];
30+
const ghURL = `https://github.com/jsmartx/giter/releases/download/v${pkg.version}/`;
31+
const url = `${ghURL}${pkg.name}_${pkg.version}_${platform}_${arch}.tar.gz`;
32+
33+
const spinner = ora(`Downloading ${url}`).start();
34+
download(url, 'bin', {
35+
extract: true
36+
}).then(() => {
37+
spinner.succeed();
38+
}).catch(() => {
39+
spinner.fail();
40+
});
41+
}
42+
43+
install();

package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "giter",
3+
"version": "0.0.5",
4+
"description": "Git users manager",
5+
"main": "cli/giter.js",
6+
"bin": {
7+
"giter": "cli/giter.js"
8+
},
9+
"scripts": {
10+
"postinstall": "node ./cli/install.js"
11+
},
12+
"files": [
13+
"cli/"
14+
],
15+
"repository": {
16+
"type": "git",
17+
"url": "git+https://github.com/jsmartx/giter.git"
18+
},
19+
"keywords": [
20+
"git",
21+
"users",
22+
"config",
23+
"manager",
24+
"ssh"
25+
],
26+
"author": "jsmartx.com",
27+
"license": "MIT",
28+
"bugs": {
29+
"url": "https://github.com/jsmartx/giter/issues"
30+
},
31+
"homepage": "https://github.com/jsmartx/giter#readme",
32+
"dependencies": {
33+
"download": "^7.1.0",
34+
"ora": "^3.0.0"
35+
}
36+
}

0 commit comments

Comments
 (0)