@cloud-cli/env 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cloud.db +0 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +10 -5
- package/package.json +1 -1
package/cloud.db
ADDED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Resource } from '@cloud-cli/store';
|
|
2
2
|
import { init } from '@cloud-cli/cli';
|
|
3
|
-
declare class EnvEntry extends Resource {
|
|
3
|
+
export declare class EnvEntry extends Resource {
|
|
4
4
|
app: string;
|
|
5
5
|
key: string;
|
|
6
6
|
value: string;
|
|
7
7
|
}
|
|
8
8
|
export interface App {
|
|
9
9
|
app: string;
|
|
10
|
+
name?: string;
|
|
10
11
|
}
|
|
11
12
|
export interface KeyValue {
|
|
12
13
|
key: string;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Model, NotNull, Property, Query, Resource, Unique } from '@cloud-cli/store';
|
|
7
|
+
import { Model, NotNull, Property, Query, Resource, SQLiteDriver, Unique } from '@cloud-cli/store';
|
|
8
8
|
import { init } from '@cloud-cli/cli';
|
|
9
9
|
const appNotSpecifiedError = new Error('App not specified');
|
|
10
10
|
const keyNotSpecifiedError = new Error('Key not specified');
|
|
@@ -26,11 +26,13 @@ __decorate([
|
|
|
26
26
|
EnvEntry = __decorate([
|
|
27
27
|
Model('env')
|
|
28
28
|
], EnvEntry);
|
|
29
|
+
export { EnvEntry };
|
|
29
30
|
async function reload() {
|
|
31
|
+
Resource.use(new SQLiteDriver());
|
|
30
32
|
await Resource.create(EnvEntry);
|
|
31
33
|
}
|
|
32
34
|
async function show(options) {
|
|
33
|
-
const
|
|
35
|
+
const app = options.app || options.name;
|
|
34
36
|
if (!app) {
|
|
35
37
|
throw appNotSpecifiedError;
|
|
36
38
|
}
|
|
@@ -41,7 +43,8 @@ async function apps() {
|
|
|
41
43
|
return Array.from(new Set(rows.map(entry => entry.app)));
|
|
42
44
|
}
|
|
43
45
|
async function set(options) {
|
|
44
|
-
const
|
|
46
|
+
const app = options.app || options.name;
|
|
47
|
+
const { key, value } = options;
|
|
45
48
|
if (!app) {
|
|
46
49
|
throw appNotSpecifiedError;
|
|
47
50
|
}
|
|
@@ -53,14 +56,16 @@ async function set(options) {
|
|
|
53
56
|
return entry;
|
|
54
57
|
}
|
|
55
58
|
async function remove(options) {
|
|
56
|
-
const
|
|
59
|
+
const app = options.app || options.name;
|
|
60
|
+
const { key } = options;
|
|
57
61
|
const found = await get({ app, key });
|
|
58
62
|
if ((found).length) {
|
|
59
63
|
return void await found[0].remove();
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
async function get(options) {
|
|
63
|
-
const
|
|
67
|
+
const app = options.app || options.name;
|
|
68
|
+
const { key } = options;
|
|
64
69
|
if (!app) {
|
|
65
70
|
throw appNotSpecifiedError;
|
|
66
71
|
}
|