forked from bsthomsen/adonis-auditable
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ahtinurme
authored and
ahtinurme
committed
Mar 26, 2020
1 parent
b06d051
commit 5ab1aac
Showing
9 changed files
with
140 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
'use strict' | ||
"use strict"; | ||
|
||
const path = require('path') | ||
const path = require("path"); | ||
|
||
async function copyAuditMigration (cli) { | ||
try { | ||
const migrationsFile = cli.helpers.migrationsPath(`${new Date().getTime()}_audit.js`) | ||
const migrationsFile = cli.helpers.migrationsPath( | ||
`${new Date().getTime()}_audit.js`); | ||
await cli.copy( | ||
path.join(__dirname, 'templates', 'AuditSchema.js'), | ||
path.join(migrationsFile) | ||
) | ||
cli.command.completed('create', migrationsFile.replace(cli.helpers.appRoot(), '').replace(path.sep, '')) | ||
} | ||
catch (error) { | ||
console.log(error) | ||
path.join(__dirname, "templates", "AuditSchema.js"), | ||
path.join(migrationsFile), | ||
); | ||
cli.command.completed("create", | ||
migrationsFile.replace(cli.helpers.appRoot(), "").replace(path.sep, "")); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
|
||
async function copyAuditModel (cli) { | ||
try { | ||
await cli.copy( | ||
path.join(__dirname, 'templates', 'Audit.js'), | ||
path.join(cli.appDir, 'Models/Audit.js') | ||
) | ||
cli.command.completed('create', 'Models/Audit.js') | ||
} | ||
catch (error) { | ||
console.log(error) | ||
path.join(__dirname, "templates", "Audit.js"), | ||
path.join(cli.appDir, "Models/Audit.js"), | ||
); | ||
cli.command.completed("create", "Models/Audit.js"); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
|
||
module.exports = async (cli) => { | ||
await copyAuditModel(cli) | ||
await copyAuditMigration(cli) | ||
} | ||
await copyAuditModel(cli); | ||
await copyAuditMigration(cli); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "adonis-auditable", | ||
"name": "adonis-audit", | ||
"version": "2.0.1", | ||
"description": "Audit AdonisJS models", | ||
"main": " ", | ||
|
@@ -8,7 +8,7 @@ | |
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/simontong/adonis-auditable.git" | ||
"url": "git+https://github.com/ahtinurme/adonis-audit.git" | ||
}, | ||
"keywords": [ | ||
"adonis", | ||
|
@@ -18,9 +18,9 @@ | |
"author": "Simon Tong <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/simontong/adonis-auditable/issues" | ||
"url": "https://github.com/ahtinurme/adonis-audit/issues" | ||
}, | ||
"homepage": "https://github.com/simontong/adonis-auditable#readme", | ||
"homepage": "https://github.com/ahtinurme/adonis-audit#readme", | ||
"dependencies": { | ||
"lodash": "^4.17.4" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const { ServiceProvider } = require("@adonisjs/fold"); | ||
|
||
class AuditProvider extends ServiceProvider { | ||
register () { | ||
this.app.singleton("Adonis/Traits/Auditable", () => { | ||
// const Config = this.app.use('Adonis/Src/Config') | ||
const Auditable = require("../src/Traits/Auditable"); | ||
return new Auditable(); | ||
}); | ||
this.app.alias("Adonis/Traits/Auditable", "Auditable"); | ||
} | ||
|
||
boot () { | ||
const Context = this.app.use("Adonis/Src/HttpContext"); | ||
const Auditable = this.app.use("Auditable"); | ||
|
||
// add ctx to datagrid | ||
Context.onReady(ctx => { | ||
Auditable.ctx = ctx; | ||
}); | ||
} | ||
} | ||
|
||
module.exports = AuditProvider; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.