1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Fixed imports

This commit is contained in:
Laurent Cozic 2017-07-05 23:29:03 +01:00
parent 23818cb428
commit 9e3a2a894e
6 changed files with 3914 additions and 73 deletions

View File

@ -1,4 +1,4 @@
import fs from 'fs-extra';
const fs = require('fs-extra');
class FsDriverNode {
@ -17,4 +17,4 @@ class FsDriverNode {
}
export { FsDriverNode }
module.exports.FsDriverNode = FsDriverNode;

View File

@ -5,7 +5,9 @@ require('babel-plugin-transform-runtime');
import { time } from 'lib/time-utils.js';
import { Logger } from 'lib/logger.js';
import { Resource } from 'lib/models/resource.js';
import { dirname } from 'lib/path-utils.js';
import { FsDriverNode } from './fs-driver-node.js';
import lodash from 'lodash';
const exec = require('child_process').exec
const fs = require('fs-extra');
@ -15,6 +17,10 @@ const syncDir = baseDir + '/sync';
const joplinAppPath = __dirname + '/main.js';
let syncDurations = [];
const fsDriver = new FsDriverNode();
Logger.fsDriver_ = fsDriver;
Resource.fsDriver_ = fsDriver;
const logger = new Logger();
logger.addTarget('console');
logger.setLevel(Logger.LEVEL_DEBUG);

View File

@ -1,71 +0,0 @@
require('source-map-support').install();
require('babel-plugin-transform-runtime');
import { OneDriveApi } from 'lib/onedrive-api.js';
const fetch = require('node-fetch');
const tcpPortUsed = require('tcp-port-used');
const http = require("http");
const urlParser = require("url");
const FormData = require('form-data');
async function main() {
let api = new OneDriveApi('e09fc0de-c958-424f-83a2-e56a721d331b', 'FAPky27RNWYuXWwThgkQE47');
let ports = api.possibleOAuthFlowPorts();
let port = null;
for (let i = 0; i < ports.length; i++) {
let inUse = await tcpPortUsed.check(ports[i]);
if (!inUse) {
port = ports[i];
break;
}
}
if (!port) throw new Error('All potential ports are in use - please report the issue at https://github.com/laurent22/joplin');
let authCodeUrl = api.authCodeUrl('http://localhost:' + port);
let server = http.createServer((request, response) => {
const query = urlParser.parse(request.url, true).query;
function writeResponse(code, message) {
response.writeHead(code, {"Content-Type": "text/html"});
response.write(message);
response.end();
}
if (!query.code) return writeResponse(400, '"code" query parameter is missing');
let url = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
let body = new FormData();
body.append('client_id', api.clientId());
body.append('client_secret', api.clientSecret());
body.append('code', query.code ? query.code : '');
body.append('redirect_uri', 'http://localhost:' + port.toString());
body.append('grant_type', 'authorization_code');
let options = {
method: 'POST',
body: body,
};
fetch(url, options).then((r) => {
if (!r.ok) {
let msg = 'Could not retrieve auth code: ' + r.status + ': ' + r.statusText;
console.info(msg);
return writeResponse(400, msg);
}
return r.json().then((json) => {
console.info(json);
return writeResponse(200, 'The application has been authorised - you may now close this browser tab.');
});
});
});
server.listen(port);
console.info(authCodeUrl);
}
main();

3897
CliClient/tests/logs/log.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,6 @@
require('source-map-support').install();
require('babel-plugin-transform-runtime');
import { time } from 'lib/time-utils.js';
import { setupDatabase, setupDatabaseAndSynchronizer, db, synchronizer, fileApi, sleep, clearDatabase, switchClient } from 'test-utils.js';
import { Folder } from 'lib/models/folder.js';

View File

@ -4,12 +4,14 @@ import { DatabaseDriverNode } from 'lib/database-driver-node.js';
import { BaseModel } from 'lib/base-model.js';
import { Folder } from 'lib/models/folder.js';
import { Note } from 'lib/models/note.js';
import { Resource } from 'lib/models/resource.js';
import { Logger } from 'lib/logger.js';
import { Setting } from 'lib/models/setting.js';
import { BaseItem } from 'lib/models/base-item.js';
import { Synchronizer } from 'lib/synchronizer.js';
import { FileApi } from 'lib/file-api.js';
import { FileApiDriverMemory } from 'lib/file-api-driver-memory.js';
import { FsDriverNode } from '../app/fs-driver-node.js';
import { time } from 'lib/time-utils.js';
let databases_ = [];
@ -17,6 +19,10 @@ let synchronizers_ = [];
let fileApi_ = null;
let currentClient_ = 1;
const fsDriver = new FsDriverNode();
Logger.fsDriver_ = fsDriver;
Resource.fsDriver_ = fsDriver;
const logger = new Logger();
logger.addTarget('file', { path: __dirname + '/../tests/logs/log.txt' });
//logger.addTarget('console');