@adonisjs/sink
Advanced tools
Comparing version 2.0.7 to 2.0.8
{ | ||
"name": "@adonisjs/sink", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"description": "Utilities to create AdonisJs boilerplates and custom providers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,6 @@ export declare class EnvFile { | ||
set(key: string, value: any): this; | ||
get(): { | ||
[key: string]: string; | ||
}; | ||
exists(): boolean; | ||
unset(key: string): this; | ||
@@ -9,0 +13,0 @@ commit(): void; |
@@ -11,4 +11,4 @@ "use strict"; | ||
set(key, value) { | ||
const matchingLine = this._envContents.get().find((line) => line.startsWith(`${key} = `)); | ||
const newText = `${key} = ${value}`; | ||
const matchingLine = this._envContents.get().find((line) => line.startsWith(`${key}=`)); | ||
const newText = `${key}=${value}`; | ||
if (matchingLine && newText !== matchingLine) { | ||
@@ -18,8 +18,18 @@ this._envContents.update(matchingLine, newText); | ||
} | ||
this._envContents.add(`${key} = ${value}`); | ||
this._exampleEnvContents.add(`${key} =`); | ||
this._envContents.add(`${key}=${value}`); | ||
this._exampleEnvContents.add(`${key}=`); | ||
return this; | ||
} | ||
get() { | ||
return this._envContents.get().reduce((result, line) => { | ||
const [key, value] = line.split('='); | ||
result[key.trim()] = value.trim(); | ||
return result; | ||
}, {}); | ||
} | ||
exists() { | ||
return this._envContents.exists(); | ||
} | ||
unset(key) { | ||
const matchingLine = this._envContents.get().find((line) => line.startsWith(`${key} =`)); | ||
const matchingLine = this._envContents.get().find((line) => line.startsWith(`${key}=`)); | ||
if (matchingLine) { | ||
@@ -29,3 +39,3 @@ this._envContents.remove(matchingLine); | ||
const exampleFileMatchingLine = this._exampleEnvContents.get().find((line) => { | ||
return line.startsWith(`${key} =`); | ||
return line.startsWith(`${key}=`); | ||
}); | ||
@@ -32,0 +42,0 @@ if (exampleFileMatchingLine) { |
@@ -15,3 +15,3 @@ import { packageJson } from 'mrm-core'; | ||
constructor(basePath: string); | ||
set(key: string, value: string): this; | ||
set(key: string, value: any): this; | ||
unset(key: string): this; | ||
@@ -24,4 +24,8 @@ setScript(name: string, script: string): this; | ||
uninstall(dependencies: string | string[], dev?: boolean): this; | ||
delete(): this; | ||
get(): any; | ||
get(address: string | string[], defaultValue?: any): any; | ||
exists(): boolean; | ||
commit(): void; | ||
rollback(): void; | ||
} |
@@ -49,5 +49,21 @@ "use strict"; | ||
} | ||
delete() { | ||
this.$addAction('delete'); | ||
return this; | ||
} | ||
get(address, defaultValue) { | ||
return address ? this.filePointer.get(address, defaultValue) : this.filePointer.get(); | ||
} | ||
exists() { | ||
return this.filePointer.exists(); | ||
} | ||
commit() { | ||
this.$cdIn(); | ||
const actions = this.$getCommitActions(); | ||
const deleteFile = actions.find(({ action }) => action === 'delete'); | ||
if (deleteFile) { | ||
this.filePointer.delete(); | ||
this.$cdOut(); | ||
return; | ||
} | ||
actions.forEach(({ action, body }) => { | ||
@@ -54,0 +70,0 @@ if (['set', 'unset'].indexOf(action) > -1) { |
@@ -12,4 +12,5 @@ import { lines } from 'mrm-core'; | ||
get(): string[]; | ||
exists(): boolean; | ||
commit(): void; | ||
rollback(): void; | ||
} |
@@ -32,2 +32,5 @@ "use strict"; | ||
} | ||
exists() { | ||
return this.filePointer.exists(); | ||
} | ||
commit() { | ||
@@ -34,0 +37,0 @@ this.$cdIn(); |
@@ -10,2 +10,3 @@ import { template } from 'mrm-core'; | ||
get(): string; | ||
exists(): boolean; | ||
apply(contents?: any): this; | ||
@@ -12,0 +13,0 @@ commit(): void; |
@@ -18,2 +18,5 @@ "use strict"; | ||
} | ||
exists() { | ||
return this.filePointer.exists(); | ||
} | ||
apply(contents) { | ||
@@ -20,0 +23,0 @@ this.filePointer.apply(contents); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
28146
746
0