Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build improvements #42

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f429372
chore: update npm org name to @titanium-sdk
sgtcoolguy Oct 15, 2019
c474651
chore(package): add husky 3.0.9
sgtcoolguy Oct 15, 2019
a006582
chore(package): update lockfile
sgtcoolguy Oct 15, 2019
b7e69d6
chore(package): add @commitlint/cli 8.2.0
sgtcoolguy Oct 15, 2019
73f9db4
chore(package): update lockfile
sgtcoolguy Oct 15, 2019
566f9ee
chore(package): add @commitlint/config-conventional 8.2.0
sgtcoolguy Oct 15, 2019
cfa5b81
chore(package): update lockfile
sgtcoolguy Oct 15, 2019
53946bf
build: hook up commitlint config
sgtcoolguy Oct 15, 2019
533921b
chore(package): add lint-staged 9.4.2
sgtcoolguy Oct 15, 2019
62dc204
chore(package): update lockfile
sgtcoolguy Oct 15, 2019
a0a6d79
build: add husky hooks
sgtcoolguy Oct 15, 2019
98db85c
chore(package): add clang-format 1.2.3
sgtcoolguy Oct 15, 2019
77cd41a
chore(package): update lockfile
sgtcoolguy Oct 15, 2019
b0b8b35
style: hook clang-format to lint-staged/husky
sgtcoolguy Oct 15, 2019
4ad256c
chore(package): add @seadub/clang-format-lint 0.0.2
sgtcoolguy Oct 15, 2019
03aa43c
chore(package): update lockfile
sgtcoolguy Oct 15, 2019
eb303a9
chore(package): update karma-titanium-launcher to 0.7.5
sgtcoolguy Oct 15, 2019
98e9d0d
chore(package): update lockfile
sgtcoolguy Oct 15, 2019
b51638c
chore(package): add commitizen 4.0.3
sgtcoolguy Oct 15, 2019
20e9f09
chore(package): update lockfile
sgtcoolguy Oct 15, 2019
d59b479
build: hook commitizen config/script
sgtcoolguy Oct 15, 2019
7af05a1
build: add npm scripts for lint/format/test
sgtcoolguy Oct 15, 2019
b384e49
chore(package): add titanium-docgen 0.2.0
sgtcoolguy Oct 15, 2019
f587cc9
chore(package): update lockfile
sgtcoolguy Oct 15, 2019
e98f66b
style: fix type whitelist for doc validation
sgtcoolguy Oct 15, 2019
48db2ed
style: add clang-format config files
sgtcoolguy Oct 15, 2019
e629173
style(android): fix formatting
sgtcoolguy Oct 15, 2019
018df7b
style(ios): fix formatting
sgtcoolguy Oct 15, 2019
0482fc0
style: add eslint config files
sgtcoolguy Oct 15, 2019
c9d24f2
style(js): fix eslint errors
sgtcoolguy Oct 15, 2019
20fa8e0
chore(package): update lockfile from npm audit fix
sgtcoolguy Oct 15, 2019
0e433b5
ci(danger): check lint log via danger.js
sgtcoolguy Oct 15, 2019
4e1aadc
chore(package): update @seadub/danger-plugin-junit to 0.1.2
sgtcoolguy Oct 15, 2019
dca6d1d
chore(package): add @seadub/danger-plugin-titanium-module@0.0.4
sgtcoolguy Feb 3, 2020
08225da
chore(package): update lockfile
sgtcoolguy Feb 3, 2020
e59af67
ci(danger): add module linting to danger.js
sgtcoolguy Feb 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules

android/bin/
android/build/
android/dist/
ios/build/
ios/dist/

# These should eventually be linted as well
example/
16 changes: 16 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": [ "axway/env-titanium", "axway/env-node" ],
"parserOptions": {
"ecmaVersion": 2015,
"sourceType": "script"
},
"overrides": [
{
"files": [ "dangerfile.js" ],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
}
}
]
}
26 changes: 26 additions & 0 deletions android/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
Language: Java
AccessModifierOffset: -4
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
# class, constructor, method should be next line
BreakBeforeBraces: Linux
# Keep '=' at end of line when wrapping, but move things like '&&', '||' to beginning of newline
BreakBeforeBinaryOperators: NonAssignment
# FIXME: break for brace after synchronized block, anonymous class declarations
BreakAfterJavaFieldAnnotations: true
ColumnLimit: 120
IndentCaseLabels: true
IndentWidth: 4
MaxEmptyLinesToKeep: 1
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpacesInParentheses: false
TabWidth: 4
UseTab: ForContinuationAndIndentation
SpaceAfterCStyleCast: true
# Spaces inside {} for array literals, i.e. "new Object[] { args }"
Cpp11BracedListStyle: false
ReflowComments: false
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
import net.sqlcipher.database.SQLiteDatabaseHook;

@Kroll.module(name = "Encrypteddatabase", id = "appcelerator.encrypteddatabase")
public class EncrypteddatabaseModule extends KrollModule {
public class EncrypteddatabaseModule extends KrollModule
{
private static final String TAG = "TiDatabase";
private String password = null;

Expand All @@ -45,30 +46,43 @@ public class EncrypteddatabaseModule extends KrollModule {
@Kroll.constant
public static final int FIELD_TYPE_DOUBLE = 3;

public EncrypteddatabaseModule() {
public EncrypteddatabaseModule()
{
super();
SQLiteDatabase.loadLibs(TiApplication.getAppCurrentActivity());
}

@Kroll.getProperty @Kroll.method
public String getPassword() {
// clang-format off
@Kroll.getProperty
@Kroll.method
public String getPassword()
// clang-format on
{
return password == null ? TiApplication.getInstance().getAppGUID() : password;
}

@Kroll.setProperty @Kroll.method
public void setPassword(String value) {
// clang-format off
@Kroll.getProperty
@Kroll.method
public void setPassword(String value)
// clang-format on
{
password = value;
}

@Kroll.method
public TiDatabaseProxy open(Object file) {
public TiDatabaseProxy open(Object file)
{
// Attempt to create/open the given database file/name.
TiDatabaseProxy dbp = null;

// Migrate database if necessary.
final SQLiteDatabaseHook migrationHook = new SQLiteDatabaseHook() {
public void preKey(SQLiteDatabase database) {}
public void postKey(SQLiteDatabase database) {
public void preKey(SQLiteDatabase database)
{
}
public void postKey(SQLiteDatabase database)
{
database.rawExecSQL("PRAGMA cipher_migrate;");
}
};
Expand All @@ -81,8 +95,9 @@ public void postKey(SQLiteDatabase database) {
String absolutePath = tiFile.getBaseFile().getNativeFile().getAbsolutePath();
Log.d(TAG, "Opening database from filesystem: " + absolutePath);

SQLiteDatabase db = SQLiteDatabase.openDatabase(absolutePath, getPassword(), null,
SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS, migrationHook);
SQLiteDatabase db = SQLiteDatabase.openDatabase(
absolutePath, getPassword(), null, SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS,
migrationHook);
if (db != null) {
dbp = new TiDatabaseProxy(db);
} else {
Expand Down Expand Up @@ -110,7 +125,8 @@ public void postKey(SQLiteDatabase database) {
}

@Kroll.method
public TiDatabaseProxy install(KrollInvocation invocation, String url, String name) throws IOException {
public TiDatabaseProxy install(KrollInvocation invocation, String url, String name) throws IOException
{
try {
// TiContext tiContext = invocation.getTiContext();
Context ctx = TiApplication.getInstance();
Expand Down
39 changes: 28 additions & 11 deletions android/src/appcelerator/encrypteddatabase/TiDatabaseProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
import net.sqlcipher.database.SQLiteDatabase;

@Kroll.proxy(parentModule = EncrypteddatabaseModule.class)
public class TiDatabaseProxy extends KrollProxy {
public class TiDatabaseProxy extends KrollProxy
{
private static final String TAG = "TiDB";

protected SQLiteDatabase db;
protected String name;
boolean statementLogging, readOnly;

public TiDatabaseProxy(String name, SQLiteDatabase db) {
public TiDatabaseProxy(String name, SQLiteDatabase db)
{
// super(tiContext);
super();
this.name = name;
Expand All @@ -38,7 +40,8 @@ public TiDatabaseProxy(String name, SQLiteDatabase db) {
}

// readonly database
public TiDatabaseProxy(SQLiteDatabase db) {
public TiDatabaseProxy(SQLiteDatabase db)
{
// super(tiContext);
super();
this.name = db.getPath();
Expand All @@ -48,7 +51,8 @@ public TiDatabaseProxy(SQLiteDatabase db) {
}

@Kroll.method
public void close() {
public void close()
{
if (db.isOpen()) {
Log.d(TAG, "Closing database: " + name, Log.DEBUG_MODE);
db.close();
Expand All @@ -58,7 +62,8 @@ public void close() {
}

@Kroll.method
public TiResultSetProxy execute(String sql, Object... args) {
public TiResultSetProxy execute(String sql, Object... args)
{
// Handle the cases where an array is passed containing the SQL query
// arguments.
// Otherwise use the variable argument list for the SQL query.
Expand Down Expand Up @@ -154,32 +159,45 @@ public TiResultSetProxy execute(String sql, Object... args) {
return rs;
}

// clang-format off
@Kroll.getProperty
@Kroll.method
public String getName() {
public String getName()
// clang-format on
{
return name;
}

// clang-format off
@Kroll.getProperty
@Kroll.method
public TiFileProxy getFile() {
public TiFileProxy getFile()
// clang-format on
{
return new TiFileProxy(TiFileFactory.createTitaniumFile(db.getPath(), false));
}

// clang-format off
@Kroll.getProperty
@Kroll.method
public int getLastInsertRowId() {
public int getLastInsertRowId()
// clang-format on
{
return (int) DatabaseUtils.longForQuery(db, "select last_insert_rowid()", null);
}

// clang-format off
@Kroll.getProperty
@Kroll.method
public int getRowsAffected() {
public int getRowsAffected()
// clang-format on
{
return (int) DatabaseUtils.longForQuery(db, "select changes()", null);
}

@Kroll.method
public void remove() {
public void remove()
{
if (readOnly) {
Log.w(TAG, name + " is a read-only database, cannot remove");
return;
Expand All @@ -196,5 +214,4 @@ public void remove() {
Log.w(TAG, "Unable to remove database, context has been reclaimed by GC: " + name);
}
}

}
Loading