@drifted/raven 0.0.13 → 0.0.20
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/{cli.js → raven.js} +41 -26
- package/package.json +4 -3
- package/test/helpers.js +1 -1
package/bin/{cli.js → raven.js}
RENAMED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
3
|
+
const CarrierPigeon = require('carrier-pigeon');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const crypto = require('crypto');
|
|
7
|
+
const RavenDataFile = require(path.join(__dirname, '..'));
|
|
9
8
|
|
|
10
9
|
var parser = new CarrierPigeon({strict: true});
|
|
11
10
|
parser.commands('version', 'usage', 'show', 'secret', 'init', 'generate', 'expose', 'conceal', 'encrypt', 'decrypt');
|
|
@@ -19,11 +18,11 @@ parser.option('location', {type: 'file', default: process.cwd()});
|
|
|
19
18
|
parser.option('verbose', {default: false});
|
|
20
19
|
|
|
21
20
|
var options = parser.parse(process.argv);
|
|
22
|
-
var command = options.command;
|
|
23
|
-
delete options.command;
|
|
24
21
|
|
|
22
|
+
var command = options.command;
|
|
25
23
|
process.chdir(options.location);
|
|
26
24
|
delete options.location;
|
|
25
|
+
delete options.command;
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
|
|
@@ -36,11 +35,15 @@ if (options.verbose) {
|
|
|
36
35
|
|
|
37
36
|
|
|
38
37
|
if (command == 'encrypt') {
|
|
39
|
-
var file = new
|
|
38
|
+
var file = new RavenDataFile(options);
|
|
40
39
|
|
|
41
40
|
var data = file.encrypt(options.data);
|
|
42
41
|
if (options.json) {
|
|
43
|
-
console.log(JSON.stringify({
|
|
42
|
+
console.log(JSON.stringify({
|
|
43
|
+
action: 'encrypt',
|
|
44
|
+
options: options,
|
|
45
|
+
data: data
|
|
46
|
+
}, null, 2))
|
|
44
47
|
} else {
|
|
45
48
|
console.log('data:', data);
|
|
46
49
|
}
|
|
@@ -53,7 +56,7 @@ if (command == 'decrypt') {
|
|
|
53
56
|
var secret = options.secret;
|
|
54
57
|
|
|
55
58
|
delete options.data;
|
|
56
|
-
var file = new
|
|
59
|
+
var file = new RavenDataFile(options);
|
|
57
60
|
var json = file.decrypt(data);
|
|
58
61
|
|
|
59
62
|
try {
|
|
@@ -64,7 +67,11 @@ if (command == 'decrypt') {
|
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
if (options.json) {
|
|
67
|
-
console.log(JSON.stringify({
|
|
70
|
+
console.log(JSON.stringify({
|
|
71
|
+
action: 'decrypt',
|
|
72
|
+
options: options,
|
|
73
|
+
data: json
|
|
74
|
+
}, null, 2))
|
|
68
75
|
} else {
|
|
69
76
|
console.log(json);
|
|
70
77
|
}
|
|
@@ -73,7 +80,7 @@ if (command == 'decrypt') {
|
|
|
73
80
|
|
|
74
81
|
|
|
75
82
|
if (command == 'generate') {
|
|
76
|
-
|
|
83
|
+
RavenDataFile.generate().then((generated) => {
|
|
77
84
|
if (options.json) {
|
|
78
85
|
|
|
79
86
|
console.log(JSON.stringify({
|
|
@@ -84,7 +91,7 @@ if (command == 'generate') {
|
|
|
84
91
|
}, null, 2))
|
|
85
92
|
|
|
86
93
|
} else {
|
|
87
|
-
console.log('file created at',
|
|
94
|
+
console.log('file created at', RavenDataFile.secretFile().replace(process.cwd()+path.sep, ''));
|
|
88
95
|
}
|
|
89
96
|
})
|
|
90
97
|
}
|
|
@@ -92,14 +99,14 @@ if (command == 'generate') {
|
|
|
92
99
|
|
|
93
100
|
|
|
94
101
|
if (command == 'init') {
|
|
95
|
-
|
|
102
|
+
RavenDataFile.init().then((initialized) => {
|
|
96
103
|
if (options.json) {
|
|
97
104
|
console.log(JSON.stringify({action: 'init', options: options, location: process.cwd(), success: initialized}, null, 2))
|
|
98
105
|
} else {
|
|
99
106
|
if (initialized) {
|
|
100
|
-
console.log('file created at',
|
|
107
|
+
console.log('file created at', RavenDataFile.secretFile().replace(process.cwd()+path.sep, ''));
|
|
101
108
|
} else {
|
|
102
|
-
console.log(
|
|
109
|
+
console.log(RavenDataFile.secretFile().replace(process.cwd()+path.sep, ''), 'already exists.');
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
})
|
|
@@ -109,16 +116,16 @@ if (command == 'init') {
|
|
|
109
116
|
|
|
110
117
|
if (command == 'secret') {
|
|
111
118
|
if (options.json) {
|
|
112
|
-
console.log(JSON.stringify({ secret:
|
|
119
|
+
console.log(JSON.stringify({ secret: RavenDataFile.secret() }, null, 2));
|
|
113
120
|
} else {
|
|
114
|
-
console.log('secret:',
|
|
121
|
+
console.log('secret:', RavenDataFile.secret());
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
|
|
119
126
|
|
|
120
127
|
if (command == 'show') {
|
|
121
|
-
var json = JSON.parse(
|
|
128
|
+
var json = JSON.parse(RavenDataFile.show());
|
|
122
129
|
if (options.json) {
|
|
123
130
|
console.log(JSON.stringify(json, null, 2));
|
|
124
131
|
} else {
|
|
@@ -129,11 +136,15 @@ if (command == 'show') {
|
|
|
129
136
|
|
|
130
137
|
|
|
131
138
|
if (command == 'expose') {
|
|
132
|
-
var file = new
|
|
133
|
-
//console.log(file);
|
|
139
|
+
var file = new RavenDataFile(options);
|
|
134
140
|
file.expose().then(() => {
|
|
135
141
|
if (options.json) {
|
|
136
|
-
console.log(JSON.stringify({
|
|
142
|
+
console.log(JSON.stringify({
|
|
143
|
+
file: file.shortPath(),
|
|
144
|
+
action: 'expose',
|
|
145
|
+
options: options,
|
|
146
|
+
secret: file.secret
|
|
147
|
+
}, null, 2))
|
|
137
148
|
} else {
|
|
138
149
|
console.log('');
|
|
139
150
|
console.log(file.shortPath(), 'decrypted');
|
|
@@ -146,11 +157,15 @@ if (command == 'expose') {
|
|
|
146
157
|
|
|
147
158
|
|
|
148
159
|
if (command == 'conceal') {
|
|
149
|
-
var file = new
|
|
150
|
-
//console.log(file);
|
|
160
|
+
var file = new RavenDataFile(options);
|
|
151
161
|
file.conceal().then(() => {
|
|
152
162
|
if (options.json) {
|
|
153
|
-
console.log(JSON.stringify({
|
|
163
|
+
console.log(JSON.stringify({
|
|
164
|
+
file: file.shortPath(),
|
|
165
|
+
action: 'conceal',
|
|
166
|
+
options: options,
|
|
167
|
+
secret: file.secret
|
|
168
|
+
}, null, 2))
|
|
154
169
|
} else {
|
|
155
170
|
console.log('');
|
|
156
171
|
console.log(file.shortPath(), 'encrypted');
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drifted/raven",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://github.com/driftless-group/raven",
|
|
6
6
|
"bin": {
|
|
7
|
-
"
|
|
7
|
+
"craven": "./bin/console.js",
|
|
8
|
+
"raven": "./bin/raven.js"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
12
|
"url": "@drifted/raven"
|
|
12
13
|
},
|
|
13
|
-
"license": "
|
|
14
|
+
"license": "GPL-3.0",
|
|
14
15
|
"author": "Scott Ballantyne",
|
|
15
16
|
"type": "commonjs",
|
|
16
17
|
"main": "index.js",
|
package/test/helpers.js
CHANGED
|
@@ -8,7 +8,7 @@ const crypto = require('crypto');
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
function run(...specifics) {
|
|
11
|
-
var parts = [process.execPath, path.join(__dirname, '..', 'bin', '
|
|
11
|
+
var parts = [process.execPath, path.join(__dirname, '..', 'bin', 'raven.js')].concat(specifics);
|
|
12
12
|
return new Promise((resolve, reject) => {
|
|
13
13
|
exec(parts.join(' '), (err, stdout, stdin) => {
|
|
14
14
|
if (err) {
|