Skip to content

Commit 24d0182

Browse files
carlosroberto555andpor
authored andcommitted
Remove old rnpm for react-native 0.60 (#361)
* remvoe old rnpm * fix project props * remove dependency * fix indentation * start enable autolink * change directory * remove configs * remove config * move files * change source_files path * remove log from production * remove console from core * export plugin log * change platfoms path again * fix ios platform podspec path
1 parent 04c34d2 commit 24d0182

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+62
-50
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ xcuserdata
5555
*.xcuserstate
5656
*.xcscmblueprint
5757
*.xcscheme
58+
.vscode
5859

5960
android/.gradle/
6061
# node.js

lib/sqlite.core.js

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,17 @@ argsArray = function(fun) {
8383

8484
plugin.exec = function(method, options, success, error) {
8585
if (plugin.sqlitePlugin.DEBUG){
86-
console.log('SQLite.' + method + '(' + JSON.stringify(options) + ')');
86+
plugin.log('SQLite.' + method + '(' + JSON.stringify(options) + ')');
8787
}
8888
NativeModules["SQLite"][method](options,success,error);
8989
};
9090

91+
plugin.log = function(...messages) {
92+
if (plugin.sqlitePlugin.DEBUG) {
93+
console.log(...messages)
94+
}
95+
}
96+
9197
SQLitePlugin = function(openargs, openSuccess, openError) {
9298
var dbname;
9399
if (!(openargs && openargs['name'])) {
@@ -102,10 +108,10 @@ SQLitePlugin = function(openargs, openSuccess, openError) {
102108
this.openSuccess = openSuccess;
103109
this.openError = openError;
104110
this.openSuccess || (this.openSuccess = function() {
105-
console.log("DB opened: " + dbname);
111+
plugin.log("DB opened: " + dbname);
106112
});
107113
this.openError || (this.openError = function(e) {
108-
console.log(e.message);
114+
plugin.log(e.message);
109115
});
110116
this.open(this.openSuccess, this.openError);
111117
};
@@ -128,9 +134,9 @@ SQLitePlugin.prototype.addTransaction = function(t) {
128134
this.startNextTransaction();
129135
} else {
130136
if (this.dbname in this.openDBs) {
131-
console.log('new transaction is waiting for open operation');
137+
plugin.log('new transaction is waiting for open operation');
132138
} else {
133-
console.log('database is closed, new transaction is [stuck] waiting until db is opened again!');
139+
plugin.log('database is closed, new transaction is [stuck] waiting until db is opened again!');
134140
}
135141
}
136142
};
@@ -158,12 +164,12 @@ SQLitePlugin.prototype.startNextTransaction = function() {
158164
return function() {
159165
var txLock;
160166
if (!(_this.dbname in _this.openDBs) || _this.openDBs[_this.dbname] !== DB_STATE_OPEN) {
161-
console.log('cannot start next transaction: database not open');
167+
plugin.log('cannot start next transaction: database not open');
162168
return;
163169
}
164170
txLock = txLocks[self.dbname];
165171
if (!txLock) {
166-
console.log('cannot start next transaction: database connection is lost');
172+
plugin.log('cannot start next transaction: database connection is lost');
167173
} else if (txLock.queue.length > 0 && !txLock.inProgress) {
168174
txLock.inProgress = true;
169175
txLock.queue.shift().start();
@@ -227,7 +233,7 @@ SQLitePlugin.prototype.sqlBatch = function(sqlStatements, success, error) {
227233
if (!!error) {
228234
return error(e);
229235
} else {
230-
console.log("Error handler not provided: ",e);
236+
plugin.log("Error handler not provided: ",e);
231237
}
232238
};
233239

@@ -239,19 +245,19 @@ SQLitePlugin.prototype.open = function(success, error) {
239245
var openerrorcb, opensuccesscb;
240246

241247
if (this.dbname in this.openDBs && this.openDBs[this.dbname] === DB_STATE_OPEN) {
242-
console.log('database already open: ' + this.dbname);
248+
plugin.log('database already open: ' + this.dbname);
243249
nextTick((function(_this) {
244250
return function() {
245251
success(_this);
246252
};
247253
})(this));
248254
} else {
249-
console.log('OPEN database: ' + this.dbname);
255+
plugin.log('OPEN database: ' + this.dbname);
250256
opensuccesscb = (function(_this) {
251257
return function() {
252258
var txLock;
253259
if (!_this.openDBs[_this.dbname]) {
254-
console.log('database was closed during open operation');
260+
plugin.log('database was closed during open operation');
255261
}
256262
if (_this.dbname in _this.openDBs) {
257263
_this.openDBs[_this.dbname] = DB_STATE_OPEN;
@@ -267,7 +273,7 @@ SQLitePlugin.prototype.open = function(success, error) {
267273
})(this);
268274
openerrorcb = (function(_this) {
269275
return function() {
270-
console.log('OPEN database: ' + _this.dbname + ' failed, aborting any pending transactions');
276+
plugin.log('OPEN database: ' + _this.dbname + ' failed, aborting any pending transactions');
271277
if (!!error) {
272278
error(newSQLError('Could not open database'));
273279
}
@@ -283,16 +289,16 @@ SQLitePlugin.prototype.open = function(success, error) {
283289
SQLitePlugin.prototype.close = function(success, error) {
284290
if (this.dbname in this.openDBs) {
285291
if (txLocks[this.dbname] && txLocks[this.dbname].inProgress) {
286-
console.log('cannot close: transaction is in progress');
292+
plugin.log('cannot close: transaction is in progress');
287293
error(newSQLError('database cannot be closed while a transaction is in progress'));
288294
return;
289295
}
290-
console.log('CLOSE database: ' + this.dbname);
296+
plugin.log('CLOSE database: ' + this.dbname);
291297
delete this.openDBs[this.dbname];
292298
if (txLocks[this.dbname]) {
293-
console.log('closing db with transaction queue length: ' + txLocks[this.dbname].queue.length);
299+
plugin.log('closing db with transaction queue length: ' + txLocks[this.dbname].queue.length);
294300
} else {
295-
console.log('closing db with no transaction lock state');
301+
plugin.log('closing db with no transaction lock state');
296302
}
297303
let mysuccess = function(t, r) {
298304
if (!!success) {
@@ -303,13 +309,13 @@ SQLitePlugin.prototype.close = function(success, error) {
303309
if (!!error) {
304310
return error(e);
305311
} else {
306-
console.log("Error handler not provided: ",e);
312+
plugin.log("Error handler not provided: ",e);
307313
}
308314
};
309315
plugin.exec("close",{path: this.dbname}, mysuccess, myerror);
310316
} else {
311317
var err = 'cannot close: database is not open';
312-
console.log(err);
318+
plugin.log(err);
313319
if (error) {
314320
nextTick(function() {
315321
return error(err);
@@ -321,11 +327,11 @@ SQLitePlugin.prototype.close = function(success, error) {
321327
SQLitePlugin.prototype.attach = function(dbNameToAttach, dbAlias, success, error) {
322328
if (this.dbname in this.openDBs) {
323329
if (txLocks[this.dbname] && txLocks[this.dbname].inProgress) {
324-
console.log('cannot attach: transaction is in progress');
330+
plugin.log('cannot attach: transaction is in progress');
325331
error(newSQLError('database cannot be attached while a transaction is in progress'));
326332
return;
327333
}
328-
console.log('ATTACH database ' + dbNameToAttach + ' to ' + this.dbname + ' with alias ' + dbAlias);
334+
plugin.log('ATTACH database ' + dbNameToAttach + ' to ' + this.dbname + ' with alias ' + dbAlias);
329335

330336
let mysuccess = function(t, r) {
331337
if (!!success) {
@@ -336,7 +342,7 @@ SQLitePlugin.prototype.attach = function(dbNameToAttach, dbAlias, success, error
336342
if (!!error) {
337343
return error(e);
338344
} else {
339-
console.log("Error handler not provided: ",e);
345+
plugin.log("Error handler not provided: ",e);
340346
}
341347
};
342348
plugin.exec("attach",{path: this.dbname, dbName: dbNameToAttach, dbAlias}, mysuccess, myerror);
@@ -353,29 +359,29 @@ SQLitePlugin.prototype.attach = function(dbNameToAttach, dbAlias, success, error
353359
SQLitePlugin.prototype.detach = function(dbAlias, success, error) {
354360
if (this.dbname in this.openDBs) {
355361
if (txLocks[this.dbname] && txLocks[this.dbname].inProgress) {
356-
console.log('cannot attach: transaction is in progress');
362+
plugin.log('cannot attach: transaction is in progress');
357363
error(newSQLError('database cannot be attached while a transaction is in progress'));
358364
return;
359365
}
360-
console.log('DETACH database ' + dbAlias + ' from ' + this.dbname);
366+
plugin.log('DETACH database ' + dbAlias + ' from ' + this.dbname);
361367

362368
let mysuccess = function(t, r) {
363369
if (!!success) {
364370
return success(r);
365371
}
366372
};
367373
let myerror = function(e) {
368-
console.log('ERR', e);
374+
plugin.log('ERR', e);
369375
if (!!error) {
370376
return error(e);
371377
} else {
372-
console.log("Error handler not provided: ",e);
378+
plugin.log("Error handler not provided: ",e);
373379
}
374380
};
375381
this.executeSql('DETACH DATABASE ' + dbAlias, [], mysuccess, myerror)
376382
} else {
377383
var err = 'cannot attach: database is not open';
378-
console.log(err);
384+
plugin.log(err);
379385
if (error) {
380386
nextTick(function() {
381387
return error(err);
@@ -395,7 +401,7 @@ SQLitePlugin.prototype.executeSql = function(statement, params, success, error)
395401
if (!!error) {
396402
return error(e);
397403
} else {
398-
console.log("Error handler not provided: ",e);
404+
plugin.log("Error handler not provided: ",e);
399405
}
400406
};
401407
myfn = function(tx) {
@@ -476,7 +482,7 @@ SQLitePluginTransaction.prototype.executeSql = function(sql, values, success, er
476482
if (!!error) {
477483
return error(e);
478484
} else {
479-
console.log("Error handler not provided: ",e);
485+
plugin.log("Error handler not provided: ",e);
480486
}
481487
};
482488
that.addStatement(sql, values, mysuccess, myerror);
@@ -498,10 +504,10 @@ SQLitePluginTransaction.prototype.addStatement = function(sql, values, success,
498504
}
499505
else if (t !== 'function') {
500506
params.push(v.toString());
501-
console.warn('addStatement - parameter of type <'+t+'> converted to string using toString()')
507+
plugin.warn('addStatement - parameter of type <'+t+'> converted to string using toString()')
502508
} else {
503509
let errorMsg = 'Unsupported parameter type <'+t+'> found in addStatement()';
504-
console.error(errorMsg);
510+
plugin.error(errorMsg);
505511
error(newSQLError(errorMsg));
506512
return;
507513
}
@@ -516,13 +522,13 @@ SQLitePluginTransaction.prototype.addStatement = function(sql, values, success,
516522
};
517523

518524
SQLitePluginTransaction.prototype.handleStatementSuccess = function(handler, response) {
519-
// console.log('handler response:',response,response.rows);
525+
// plugin.log('handler response:',response,response.rows);
520526
var payload, rows;
521527
if (!handler) {
522528
return;
523529
}
524530
rows = response.rows || [];
525-
// console.log('handler rows now:',rows);
531+
// plugin.log('handler rows now:',rows);
526532
payload = {
527533
rows: {
528534
item: function(i) {
@@ -540,7 +546,7 @@ SQLitePluginTransaction.prototype.handleStatementSuccess = function(handler, res
540546
rowsAffected: response.rowsAffected || 0,
541547
insertId: response.insertId || void 0
542548
};
543-
// console.log('handler response payload:',payload);
549+
// plugin.log('handler response payload:',payload);
544550
handler(this, payload);
545551
};
546552

@@ -573,7 +579,7 @@ SQLitePluginTransaction.prototype.run = function() {
573579
} catch (err) {
574580
let errorMsg = JSON.stringify(err);
575581
if(errorMsg === "{}") errorMsg = err.toString();
576-
console.log("warning - exception while invoking a callback: " + errorMsg);
582+
plugin.log("warning - exception while invoking a callback: " + errorMsg);
577583
}
578584

579585
if (!didSucceed) {
@@ -629,7 +635,7 @@ SQLitePluginTransaction.prototype.run = function() {
629635
};
630636

631637
var myerror = function(error) {
632-
console.log("batch execution error: ",error);
638+
plugin.log("batch execution error: ",error);
633639
};
634640

635641
plugin.exec("backgroundExecuteSqlBatch",{
@@ -713,7 +719,7 @@ dblocations = {
713719
SQLiteFactory = function(){};
714720

715721
SQLiteFactory.prototype.DEBUG = function(debug) {
716-
console.log("Setting debug to:",debug);
722+
plugin.log("Setting debug to:",debug);
717723
plugin.sqlitePlugin.DEBUG = debug;
718724
};
719725

@@ -821,7 +827,7 @@ SQLiteFactory.prototype.deleteDatabase = function(first,success, error) {
821827
if (!!error) {
822828
return error(e);
823829
} else {
824-
console.log("deleteDatabase error handler not provided: ",e);
830+
plugin.log("deleteDatabase error handler not provided: ",e);
825831
}
826832
};
827833

@@ -831,7 +837,8 @@ SQLiteFactory.prototype.deleteDatabase = function(first,success, error) {
831837
plugin.sqlitePlugin = {
832838
SQLiteFactory : SQLiteFactory,
833839
SQLitePluginTransaction : SQLitePluginTransaction,
834-
SQLitePlugin : SQLitePlugin
840+
SQLitePlugin : SQLitePlugin,
841+
log: plugin.log
835842
};
836843

837844
module.exports = plugin.sqlitePlugin;

package.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,5 @@
3131
"homepage": "https://github.com/andpor/react-native-sqlite-storage",
3232
"peerDependencies": {
3333
"react-native": ">=0.14.0"
34-
},
35-
"rnpm": {
36-
"ios": {
37-
"project": "src/ios/SQLite.xcodeproj"
38-
},
39-
"android": {
40-
"sourceDir": "src/android"
41-
}
4234
}
4335
}

0 commit comments

Comments
 (0)