Merged 1.3.x_branch into master
This commit is contained in:
12
README.md
12
README.md
@@ -40,6 +40,18 @@ also be set to a strong, random password.
|
||||
* For Skynet mounts, add `-sk` argument to all commands listed above.
|
||||
* For ScPrime mounts, add `-sp` argument to all commands listed above.
|
||||
|
||||
## Module Environment Variables
|
||||
|
||||
* To successfully complete unit tests, a `repertory` mount supporting remote mount needs to be
|
||||
active. Set the following environment variables prior to running tests:
|
||||
* `TEST_HOST`
|
||||
* `TEST_PASSWORD`
|
||||
* `TEST_PORT`
|
||||
* To override the version being sent to `repertory`, set the following variable:
|
||||
* `REPERTORY_JS_FORCE_VERSION`
|
||||
* NOTE: This variable is primarily used for debugging/testing purposes and should normally
|
||||
NOT be set.
|
||||
|
||||
## Example API Usage
|
||||
|
||||
```javascript
|
||||
|
||||
27
src/__tests__/constants.test.js
Normal file
27
src/__tests__/constants.test.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import {get_version, instance_id, package_json} from '../utils/constants'
|
||||
|
||||
const uuid = require('uuid');
|
||||
|
||||
test(`can read 'package.json'`, () => {
|
||||
console.log(package_json);
|
||||
expect(package_json).toBeDefined();
|
||||
});
|
||||
|
||||
test(`'instance_id' is valid`, () => {
|
||||
console.log(instance_id);
|
||||
expect(instance_id).toBeDefined();
|
||||
expect(uuid.parse(instance_id)).toBeInstanceOf(Uint8Array);
|
||||
});
|
||||
|
||||
test(`'version' can be read from 'package.json'`, () => {
|
||||
console.log(get_version());
|
||||
expect(get_version()).toBe('1.3.1-r1');
|
||||
});
|
||||
|
||||
test(`'version' can be overridden by environment variable`, () => {
|
||||
console.log(process.env);
|
||||
process.env.REPERTORY_JS_FORCE_VERSION = '1.3.0';
|
||||
console.log(get_version());
|
||||
expect(get_version()).toBe('1.3.0');
|
||||
console.log(process.env);
|
||||
});
|
||||
@@ -1,6 +1,5 @@
|
||||
import Socket from 'net';
|
||||
|
||||
import package_json from '../../package.json'
|
||||
import * as constants from '../utils/constants'
|
||||
|
||||
import packet from './packet';
|
||||
@@ -18,8 +17,8 @@ export default class connection {
|
||||
}
|
||||
|
||||
connected = false;
|
||||
host_or_ip = "";
|
||||
password = "";
|
||||
host_or_ip = '';
|
||||
password = '';
|
||||
port = 20000;
|
||||
reject;
|
||||
resolve;
|
||||
@@ -73,8 +72,12 @@ export default class connection {
|
||||
const response = new packet(this.password);
|
||||
response.buffer = new Uint8Array(packet_data);
|
||||
response.decrypt()
|
||||
.then(() => {resolve(response)})
|
||||
.catch(e => {reject(e)})
|
||||
.then(() => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch(e => {
|
||||
reject(e)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,11 +123,9 @@ export default class connection {
|
||||
packet.token = this.password;
|
||||
packet.encode_top_utf8(method_name);
|
||||
packet.encode_top_ui64(optional_thread_id || 1);
|
||||
packet.encode_top_utf8(
|
||||
constants.instance_id ||
|
||||
'c2e3da6656a9f5cd7b95f159687da459656738af7a6d0de533f526d67af14cac');
|
||||
packet.encode_top_utf8(constants.instance_id);
|
||||
packet.encode_top_ui32(0); // Service flags
|
||||
packet.encode_top_utf8(package_json.version);
|
||||
packet.encode_top_utf8(constants.get_version());
|
||||
await packet.encrypt();
|
||||
packet.encode_top_ui32(packet.buffer.length);
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
const {v4: uuidv4} = require('uuid');
|
||||
import _package_json from '../../package.json'
|
||||
|
||||
export const instance_id = uuidv4();
|
||||
export const package_json = _package_json;
|
||||
export const get_version = () => process.env.REPERTORY_JS_FORCE_VERSION || _package_json.version;
|
||||
|
||||
Reference in New Issue
Block a user