@teambit/config-store 0.0.0-0a1c5597b19267cf5009b21ff79d851ae9310c7a
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/dist/config-cmd.d.ts +15 -0
- package/dist/config-cmd.js +157 -0
- package/dist/config-cmd.js.map +1 -0
- package/dist/config-getter.d.ts +43 -0
- package/dist/config-getter.js +170 -0
- package/dist/config-getter.js.map +1 -0
- package/dist/config-store.aspect.d.ts +2 -0
- package/dist/config-store.aspect.js +18 -0
- package/dist/config-store.aspect.js.map +1 -0
- package/dist/config-store.main.runtime.d.ts +27 -0
- package/dist/config-store.main.runtime.js +127 -0
- package/dist/config-store.main.runtime.js.map +1 -0
- package/dist/global-config.d.ts +11 -0
- package/dist/global-config.js +91 -0
- package/dist/global-config.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1752188910074.js +7 -0
- package/package.json +58 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +42 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
2
|
+
import { ConfigStoreMain } from './config-store.main.runtime';
|
3
|
+
export declare class ConfigCmd implements Command {
|
4
|
+
private configStore;
|
5
|
+
name: string;
|
6
|
+
description: string;
|
7
|
+
extendedDescription: string;
|
8
|
+
group: string;
|
9
|
+
alias: string;
|
10
|
+
loadAspects: boolean;
|
11
|
+
commands: Command[];
|
12
|
+
options: CommandOptions;
|
13
|
+
constructor(configStore: ConfigStoreMain);
|
14
|
+
report(): Promise<string>;
|
15
|
+
}
|
@@ -0,0 +1,157 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.ConfigCmd = void 0;
|
7
|
+
function _chalk() {
|
8
|
+
const data = _interopRequireDefault(require("chalk"));
|
9
|
+
_chalk = function () {
|
10
|
+
return data;
|
11
|
+
};
|
12
|
+
return data;
|
13
|
+
}
|
14
|
+
function _padRight() {
|
15
|
+
const data = _interopRequireDefault(require("pad-right"));
|
16
|
+
_padRight = function () {
|
17
|
+
return data;
|
18
|
+
};
|
19
|
+
return data;
|
20
|
+
}
|
21
|
+
function _legacy() {
|
22
|
+
const data = require("@teambit/legacy.constants");
|
23
|
+
_legacy = function () {
|
24
|
+
return data;
|
25
|
+
};
|
26
|
+
return data;
|
27
|
+
}
|
28
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
29
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
30
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
31
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint max-classes-per-file: 0 */
|
32
|
+
class ConfigSet {
|
33
|
+
constructor(configStore) {
|
34
|
+
this.configStore = configStore;
|
35
|
+
_defineProperty(this, "name", 'set <key> <val>');
|
36
|
+
_defineProperty(this, "description", 'set a configuration. default to save it globally');
|
37
|
+
_defineProperty(this, "extendedDescription", `to set temporary configuration by env variable, prefix with "BIT_CONFIG", replace "." with "_" and change to upper case.
|
38
|
+
for example, "user.token" becomes "BIT_CONFIG_USER_TOKEN"`);
|
39
|
+
_defineProperty(this, "baseUrl", 'reference/config/bit-config/');
|
40
|
+
_defineProperty(this, "alias", '');
|
41
|
+
_defineProperty(this, "skipWorkspace", true);
|
42
|
+
_defineProperty(this, "options", [['l', 'local', 'set the configuration in the current scope (saved in .bit/scope.json)'], ['t', 'local-track', 'set the configuration in the current workspace (saved in workspace.jsonc)']]);
|
43
|
+
}
|
44
|
+
async report([key, value], {
|
45
|
+
local,
|
46
|
+
localTrack
|
47
|
+
}) {
|
48
|
+
const getOrigin = () => {
|
49
|
+
if (local) return 'scope';
|
50
|
+
if (localTrack) return 'workspace';
|
51
|
+
return 'global';
|
52
|
+
};
|
53
|
+
await this.configStore.setConfig(key, value, getOrigin());
|
54
|
+
return _chalk().default.green('added configuration successfully');
|
55
|
+
}
|
56
|
+
}
|
57
|
+
class ConfigGet {
|
58
|
+
constructor(configStore) {
|
59
|
+
this.configStore = configStore;
|
60
|
+
_defineProperty(this, "name", 'get <key>');
|
61
|
+
_defineProperty(this, "description", 'get a value from global configuration');
|
62
|
+
_defineProperty(this, "alias", '');
|
63
|
+
_defineProperty(this, "options", []);
|
64
|
+
}
|
65
|
+
async report([key]) {
|
66
|
+
const value = this.configStore.getConfig(key);
|
67
|
+
return value || '';
|
68
|
+
}
|
69
|
+
}
|
70
|
+
class ConfigList {
|
71
|
+
constructor(configStore) {
|
72
|
+
this.configStore = configStore;
|
73
|
+
_defineProperty(this, "name", 'list');
|
74
|
+
_defineProperty(this, "description", 'list all configuration(s)');
|
75
|
+
_defineProperty(this, "alias", '');
|
76
|
+
_defineProperty(this, "options", [['o', 'origin <origin>', 'list configuration specifically from the following: [scope, workspace, global]'], ['d', 'detailed', 'list all configuration(s) with the origin'], ['j', 'json', 'output as JSON']]);
|
77
|
+
}
|
78
|
+
async report(_, {
|
79
|
+
origin,
|
80
|
+
detailed
|
81
|
+
}) {
|
82
|
+
const objToFormattedString = conf => {
|
83
|
+
return Object.entries(conf).map(tuple => {
|
84
|
+
tuple[0] = (0, _padRight().default)(tuple[0], 45, ' ');
|
85
|
+
return tuple.join('');
|
86
|
+
}).join('\n');
|
87
|
+
};
|
88
|
+
if (origin) {
|
89
|
+
const conf = this.configStore.stores[origin].list();
|
90
|
+
return objToFormattedString(conf);
|
91
|
+
}
|
92
|
+
if (detailed) {
|
93
|
+
const formatTitle = str => _chalk().default.bold(str.toUpperCase());
|
94
|
+
const origins = Object.keys(this.configStore.stores).map(originName => {
|
95
|
+
const conf = this.configStore.stores[originName].list();
|
96
|
+
return formatTitle(originName) + '\n' + objToFormattedString(conf);
|
97
|
+
}).join('\n\n');
|
98
|
+
const combined = this.configStore.listConfig();
|
99
|
+
const combinedFormatted = objToFormattedString(combined);
|
100
|
+
return `${origins}\n\n${formatTitle('All Combined')}\n${combinedFormatted}`;
|
101
|
+
}
|
102
|
+
const conf = this.configStore.listConfig();
|
103
|
+
return objToFormattedString(conf);
|
104
|
+
}
|
105
|
+
async json(_, {
|
106
|
+
origin,
|
107
|
+
detailed
|
108
|
+
}) {
|
109
|
+
if (origin) {
|
110
|
+
return this.configStore.stores[origin].list();
|
111
|
+
}
|
112
|
+
if (detailed) {
|
113
|
+
const allStores = Object.keys(this.configStore.stores).reduce((acc, current) => {
|
114
|
+
acc[current] = this.configStore.stores[current].list();
|
115
|
+
return acc;
|
116
|
+
}, {});
|
117
|
+
allStores.combined = this.configStore.listConfig();
|
118
|
+
return allStores;
|
119
|
+
}
|
120
|
+
return this.configStore.listConfig();
|
121
|
+
}
|
122
|
+
}
|
123
|
+
class ConfigDel {
|
124
|
+
constructor(configStore) {
|
125
|
+
this.configStore = configStore;
|
126
|
+
_defineProperty(this, "name", 'del <key>');
|
127
|
+
_defineProperty(this, "description", 'delete given key from global configuration');
|
128
|
+
_defineProperty(this, "alias", '');
|
129
|
+
_defineProperty(this, "options", [['o', 'origin <origin>', 'default to delete whenever it found first. specify to delete specifically from the following: [scope, workspace, global]']]);
|
130
|
+
}
|
131
|
+
async report([key], {
|
132
|
+
origin
|
133
|
+
}) {
|
134
|
+
await this.configStore.delConfig(key, origin);
|
135
|
+
return _chalk().default.green('deleted successfully');
|
136
|
+
}
|
137
|
+
}
|
138
|
+
class ConfigCmd {
|
139
|
+
constructor(configStore) {
|
140
|
+
this.configStore = configStore;
|
141
|
+
_defineProperty(this, "name", 'config');
|
142
|
+
_defineProperty(this, "description", 'config management');
|
143
|
+
_defineProperty(this, "extendedDescription", `${_legacy().BASE_DOCS_DOMAIN}reference/config/bit-config`);
|
144
|
+
_defineProperty(this, "group", 'system');
|
145
|
+
_defineProperty(this, "alias", '');
|
146
|
+
_defineProperty(this, "loadAspects", false);
|
147
|
+
_defineProperty(this, "commands", []);
|
148
|
+
_defineProperty(this, "options", []);
|
149
|
+
this.commands = [new ConfigSet(configStore), new ConfigDel(configStore), new ConfigGet(configStore), new ConfigList(configStore)];
|
150
|
+
}
|
151
|
+
async report() {
|
152
|
+
return new ConfigList(this.configStore).report(undefined, {});
|
153
|
+
}
|
154
|
+
}
|
155
|
+
exports.ConfigCmd = ConfigCmd;
|
156
|
+
|
157
|
+
//# sourceMappingURL=config-cmd.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_padRight","_legacy","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ConfigSet","constructor","configStore","report","key","local","localTrack","getOrigin","setConfig","chalk","green","ConfigGet","getConfig","ConfigList","_","origin","detailed","objToFormattedString","conf","entries","map","tuple","rightpad","join","stores","list","formatTitle","str","bold","toUpperCase","origins","keys","originName","combined","listConfig","combinedFormatted","json","allStores","reduce","acc","current","ConfigDel","delConfig","ConfigCmd","BASE_DOCS_DOMAIN","commands","undefined","exports"],"sources":["config-cmd.ts"],"sourcesContent":["/* eslint max-classes-per-file: 0 */\nimport chalk from 'chalk';\nimport rightpad from 'pad-right';\nimport { BASE_DOCS_DOMAIN } from '@teambit/legacy.constants';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { ConfigStoreMain, StoreOrigin } from './config-store.main.runtime';\n\nclass ConfigSet implements Command {\n name = 'set <key> <val>';\n description = 'set a configuration. default to save it globally';\n extendedDescription = `to set temporary configuration by env variable, prefix with \"BIT_CONFIG\", replace \".\" with \"_\" and change to upper case.\nfor example, \"user.token\" becomes \"BIT_CONFIG_USER_TOKEN\"`;\n baseUrl = 'reference/config/bit-config/';\n alias = '';\n skipWorkspace = true;\n options = [\n ['l', 'local', 'set the configuration in the current scope (saved in .bit/scope.json)'],\n ['t', 'local-track', 'set the configuration in the current workspace (saved in workspace.jsonc)'],\n ] as CommandOptions;\n\n constructor(private configStore: ConfigStoreMain) {}\n\n async report([key, value]: [string, string], { local, localTrack }: { local?: boolean; localTrack?: boolean }) {\n const getOrigin = () => {\n if (local) return 'scope';\n if (localTrack) return 'workspace';\n return 'global';\n };\n await this.configStore.setConfig(key, value, getOrigin());\n return chalk.green('added configuration successfully');\n }\n}\n\nclass ConfigGet implements Command {\n name = 'get <key>';\n description = 'get a value from global configuration';\n alias = '';\n options = [] as CommandOptions;\n\n constructor(private configStore: ConfigStoreMain) {}\n\n async report([key]: [string]) {\n const value = this.configStore.getConfig(key);\n return value || '';\n }\n}\n\nclass ConfigList implements Command {\n name = 'list';\n description = 'list all configuration(s)';\n alias = '';\n options = [\n ['o', 'origin <origin>', 'list configuration specifically from the following: [scope, workspace, global]'],\n ['d', 'detailed', 'list all configuration(s) with the origin'],\n ['j', 'json', 'output as JSON'],\n ] as CommandOptions;\n\n constructor(private configStore: ConfigStoreMain) {}\n\n async report(_, { origin, detailed }: { origin?: StoreOrigin; detailed?: boolean }) {\n const objToFormattedString = (conf: Record<string, string>) => {\n return Object.entries(conf)\n .map((tuple) => {\n tuple[0] = rightpad(tuple[0], 45, ' ');\n return tuple.join('');\n })\n .join('\\n');\n };\n\n if (origin) {\n const conf = this.configStore.stores[origin].list();\n return objToFormattedString(conf);\n }\n\n if (detailed) {\n const formatTitle = (str: string) => chalk.bold(str.toUpperCase());\n const origins = Object.keys(this.configStore.stores)\n .map((originName) => {\n const conf = this.configStore.stores[originName].list();\n return formatTitle(originName) + '\\n' + objToFormattedString(conf);\n })\n .join('\\n\\n');\n const combined = this.configStore.listConfig();\n\n const combinedFormatted = objToFormattedString(combined);\n return `${origins}\\n\\n${formatTitle('All Combined')}\\n${combinedFormatted}`;\n }\n\n const conf = this.configStore.listConfig();\n return objToFormattedString(conf);\n }\n\n async json(_, { origin, detailed }: { origin?: StoreOrigin; detailed?: boolean }) {\n if (origin) {\n return this.configStore.stores[origin].list();\n }\n if (detailed) {\n const allStores = Object.keys(this.configStore.stores).reduce(\n (acc, current) => {\n acc[current] = this.configStore.stores[current].list();\n return acc;\n },\n {} as Record<string, Record<string, string>>\n );\n allStores.combined = this.configStore.listConfig();\n return allStores;\n }\n return this.configStore.listConfig();\n }\n}\n\nclass ConfigDel implements Command {\n name = 'del <key>';\n description = 'delete given key from global configuration';\n alias = '';\n options = [\n [\n 'o',\n 'origin <origin>',\n 'default to delete whenever it found first. specify to delete specifically from the following: [scope, workspace, global]',\n ],\n ] as CommandOptions;\n\n constructor(private configStore: ConfigStoreMain) {}\n\n async report([key]: [string], { origin }: { origin?: StoreOrigin }) {\n await this.configStore.delConfig(key, origin);\n return chalk.green('deleted successfully');\n }\n}\n\nexport class ConfigCmd implements Command {\n name = 'config';\n description = 'config management';\n extendedDescription = `${BASE_DOCS_DOMAIN}reference/config/bit-config`;\n group = 'system';\n alias = '';\n loadAspects = false;\n commands: Command[] = [];\n options = [] as CommandOptions;\n\n constructor(private configStore: ConfigStoreMain) {\n this.commands = [\n new ConfigSet(configStore),\n new ConfigDel(configStore),\n new ConfigGet(configStore),\n new ConfigList(configStore),\n ];\n }\n\n async report() {\n return new ConfigList(this.configStore).report(undefined, {});\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,I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kD;EAEnD,MAAMqB,MAAMA,CAAC,CAACC,GAAG,CAAW,EAAE;IAAEW;EAAiC,CAAC,EAAE;IAClE,MAAM,IAAI,CAACb,WAAW,CAACwC,SAAS,CAACtC,GAAG,EAAEW,MAAM,CAAC;IAC7C,OAAON,gBAAK,CAACC,KAAK,CAAC,sBAAsB,CAAC;EAC5C;AACF;AAEO,MAAMiC,SAAS,CAAoB;EAUxC1C,WAAWA,CAASC,WAA4B,EAAE;IAAA,KAA9BA,WAA4B,GAA5BA,WAA4B;IAAApB,eAAA,eATzC,QAAQ;IAAAA,eAAA,sBACD,mBAAmB;IAAAA,eAAA,8BACX,GAAG8D,0BAAgB,6BAA6B;IAAA9D,eAAA,gBAC9D,QAAQ;IAAAA,eAAA,gBACR,EAAE;IAAAA,eAAA,sBACI,KAAK;IAAAA,eAAA,mBACG,EAAE;IAAAA,eAAA,kBACd,EAAE;IAGV,IAAI,CAAC+D,QAAQ,GAAG,CACd,IAAI7C,SAAS,CAACE,WAAW,CAAC,EAC1B,IAAIuC,SAAS,CAACvC,WAAW,CAAC,EAC1B,IAAIS,SAAS,CAACT,WAAW,CAAC,EAC1B,IAAIW,UAAU,CAACX,WAAW,CAAC,CAC5B;EACH;EAEA,MAAMC,MAAMA,CAAA,EAAG;IACb,OAAO,IAAIU,UAAU,CAAC,IAAI,CAACX,WAAW,CAAC,CAACC,MAAM,CAAC2C,SAAS,EAAE,CAAC,CAAC,CAAC;EAC/D;AACF;AAACC,OAAA,CAAAJ,SAAA,GAAAA,SAAA","ignoreList":[]}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { GlobalConfig } from './global-config';
|
2
|
+
export declare const ENV_VARIABLE_CONFIG_PREFIX = "BIT_CONFIG_";
|
3
|
+
export interface Store {
|
4
|
+
list(): Record<string, string>;
|
5
|
+
set(key: string, value: string): void;
|
6
|
+
del(key: string): void;
|
7
|
+
write(): Promise<void>;
|
8
|
+
getPath(): string;
|
9
|
+
invalidateCache(): Promise<void>;
|
10
|
+
}
|
11
|
+
/**
|
12
|
+
* Singleton cache for the config object. so it can be used everywhere even by non-aspects components.
|
13
|
+
*/
|
14
|
+
export declare class ConfigGetter {
|
15
|
+
private _store;
|
16
|
+
private _globalConfig;
|
17
|
+
private gitStore;
|
18
|
+
get globalConfig(): GlobalConfig;
|
19
|
+
get store(): Record<string, string>;
|
20
|
+
/**
|
21
|
+
* in case a config-key exists in both, the new one (the given store) wins.
|
22
|
+
*/
|
23
|
+
addStore(store: Store): void;
|
24
|
+
getConfig(key: string): string | undefined;
|
25
|
+
private getFromGit;
|
26
|
+
getConfigNumeric(key: string): number | undefined;
|
27
|
+
getConfigBoolean(key: string): boolean | undefined;
|
28
|
+
listConfig(): Record<string, string>;
|
29
|
+
invalidateCache(): void;
|
30
|
+
getGlobalStore(): Store;
|
31
|
+
}
|
32
|
+
export declare const configGetter: ConfigGetter;
|
33
|
+
export declare function getConfig(key: string): string | undefined;
|
34
|
+
export declare function getNumberFromConfig(key: string): number | undefined;
|
35
|
+
export declare function listConfig(): Record<string, string>;
|
36
|
+
/**
|
37
|
+
* @deprecated use setConfig from the ConfigStore aspect instance
|
38
|
+
*/
|
39
|
+
export declare function setGlobalConfig(key: string, val: string): void;
|
40
|
+
/**
|
41
|
+
* @deprecated use delConfig from the ConfigStore aspect instance
|
42
|
+
*/
|
43
|
+
export declare function delGlobalConfig(key: string): void;
|
@@ -0,0 +1,170 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.configGetter = exports.ENV_VARIABLE_CONFIG_PREFIX = exports.ConfigGetter = void 0;
|
7
|
+
exports.delGlobalConfig = delGlobalConfig;
|
8
|
+
exports.getConfig = getConfig;
|
9
|
+
exports.getNumberFromConfig = getNumberFromConfig;
|
10
|
+
exports.listConfig = listConfig;
|
11
|
+
exports.setGlobalConfig = setGlobalConfig;
|
12
|
+
function _gitconfig() {
|
13
|
+
const data = _interopRequireDefault(require("@teambit/gitconfig"));
|
14
|
+
_gitconfig = function () {
|
15
|
+
return data;
|
16
|
+
};
|
17
|
+
return data;
|
18
|
+
}
|
19
|
+
function _lodash() {
|
20
|
+
const data = require("lodash");
|
21
|
+
_lodash = function () {
|
22
|
+
return data;
|
23
|
+
};
|
24
|
+
return data;
|
25
|
+
}
|
26
|
+
function _globalConfig() {
|
27
|
+
const data = require("./global-config");
|
28
|
+
_globalConfig = function () {
|
29
|
+
return data;
|
30
|
+
};
|
31
|
+
return data;
|
32
|
+
}
|
33
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
34
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
35
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
36
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
37
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
38
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
39
|
+
const ENV_VARIABLE_CONFIG_PREFIX = exports.ENV_VARIABLE_CONFIG_PREFIX = 'BIT_CONFIG_';
|
40
|
+
/**
|
41
|
+
* Singleton cache for the config object. so it can be used everywhere even by non-aspects components.
|
42
|
+
*/
|
43
|
+
class ConfigGetter {
|
44
|
+
constructor() {
|
45
|
+
_defineProperty(this, "_store", void 0);
|
46
|
+
_defineProperty(this, "_globalConfig", void 0);
|
47
|
+
_defineProperty(this, "gitStore", {});
|
48
|
+
}
|
49
|
+
get globalConfig() {
|
50
|
+
if (!this._globalConfig) {
|
51
|
+
this._globalConfig = _globalConfig().GlobalConfig.loadSync();
|
52
|
+
}
|
53
|
+
return this._globalConfig;
|
54
|
+
}
|
55
|
+
get store() {
|
56
|
+
if (!this._store) {
|
57
|
+
this._store = this.globalConfig.toPlainObject();
|
58
|
+
}
|
59
|
+
return this._store;
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* in case a config-key exists in both, the new one (the given store) wins.
|
64
|
+
*/
|
65
|
+
addStore(store) {
|
66
|
+
const currentStore = this.store;
|
67
|
+
this._store = _objectSpread(_objectSpread({}, currentStore), store.list());
|
68
|
+
}
|
69
|
+
getConfig(key) {
|
70
|
+
if (!key) {
|
71
|
+
return undefined;
|
72
|
+
}
|
73
|
+
const envVarName = toEnvVariableName(key);
|
74
|
+
if (process.env[envVarName]) {
|
75
|
+
return process.env[envVarName];
|
76
|
+
}
|
77
|
+
const store = this.store;
|
78
|
+
const val = store[key];
|
79
|
+
if (!(0, _lodash().isNil)(val)) {
|
80
|
+
return val;
|
81
|
+
}
|
82
|
+
const gitKeys = ['user.name', 'user.email'];
|
83
|
+
if (gitKeys.includes(key)) {
|
84
|
+
return this.getFromGit(key);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
getFromGit(key) {
|
88
|
+
if (key in this.gitStore) {
|
89
|
+
return this.gitStore[key];
|
90
|
+
}
|
91
|
+
try {
|
92
|
+
const gitVal = _gitconfig().default.get.sync(key);
|
93
|
+
this.gitStore[key] = gitVal;
|
94
|
+
} catch {
|
95
|
+
// Ignore error from git config get
|
96
|
+
this.gitStore[key] = undefined;
|
97
|
+
}
|
98
|
+
return this.gitStore[key];
|
99
|
+
}
|
100
|
+
getConfigNumeric(key) {
|
101
|
+
const fromConfig = this.getConfig(key);
|
102
|
+
if ((0, _lodash().isNil)(fromConfig)) return undefined;
|
103
|
+
const num = Number(fromConfig);
|
104
|
+
if (Number.isNaN(num)) {
|
105
|
+
throw new Error(`config of "${key}" is invalid. Expected number, got "${fromConfig}"`);
|
106
|
+
}
|
107
|
+
return num;
|
108
|
+
}
|
109
|
+
getConfigBoolean(key) {
|
110
|
+
const result = this.getConfig(key);
|
111
|
+
if ((0, _lodash().isNil)(result)) return undefined;
|
112
|
+
if (typeof result === 'boolean') return result;
|
113
|
+
if (result === 'true') return true;
|
114
|
+
if (result === 'false') return false;
|
115
|
+
throw new Error(`the configuration "${key}" has an invalid value "${result}". it should be boolean`);
|
116
|
+
}
|
117
|
+
listConfig() {
|
118
|
+
const store = this.store;
|
119
|
+
return store;
|
120
|
+
}
|
121
|
+
invalidateCache() {
|
122
|
+
this._store = undefined;
|
123
|
+
}
|
124
|
+
getGlobalStore() {
|
125
|
+
return {
|
126
|
+
list: () => this.globalConfig.toPlainObject(),
|
127
|
+
set: (key, value) => this.globalConfig.set(key, value),
|
128
|
+
del: key => this.globalConfig.delete(key),
|
129
|
+
write: async () => this.globalConfig.write(),
|
130
|
+
invalidateCache: async () => this._globalConfig = undefined,
|
131
|
+
getPath: () => (0, _globalConfig().getGlobalConfigPath)()
|
132
|
+
};
|
133
|
+
}
|
134
|
+
}
|
135
|
+
exports.ConfigGetter = ConfigGetter;
|
136
|
+
const configGetter = exports.configGetter = new ConfigGetter();
|
137
|
+
function getConfig(key) {
|
138
|
+
return configGetter.getConfig(key);
|
139
|
+
}
|
140
|
+
function getNumberFromConfig(key) {
|
141
|
+
return configGetter.getConfigNumeric(key);
|
142
|
+
}
|
143
|
+
function listConfig() {
|
144
|
+
return configGetter.listConfig();
|
145
|
+
}
|
146
|
+
/**
|
147
|
+
* @deprecated use setConfig from the ConfigStore aspect instance
|
148
|
+
*/
|
149
|
+
function setGlobalConfig(key, val) {
|
150
|
+
const globalStore = configGetter.getGlobalStore();
|
151
|
+
globalStore.set(key, val);
|
152
|
+
configGetter.globalConfig.writeSync();
|
153
|
+
globalStore.invalidateCache().catch(() => {});
|
154
|
+
configGetter.invalidateCache();
|
155
|
+
}
|
156
|
+
/**
|
157
|
+
* @deprecated use delConfig from the ConfigStore aspect instance
|
158
|
+
*/
|
159
|
+
function delGlobalConfig(key) {
|
160
|
+
const globalStore = configGetter.getGlobalStore();
|
161
|
+
globalStore.del(key);
|
162
|
+
configGetter.globalConfig.writeSync();
|
163
|
+
globalStore.invalidateCache().catch(() => {});
|
164
|
+
configGetter.invalidateCache();
|
165
|
+
}
|
166
|
+
function toEnvVariableName(configName) {
|
167
|
+
return `${ENV_VARIABLE_CONFIG_PREFIX}${configName.replace(/\./g, '_').toUpperCase()}`;
|
168
|
+
}
|
169
|
+
|
170
|
+
//# sourceMappingURL=config-getter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_gitconfig","data","_interopRequireDefault","require","_lodash","_globalConfig","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ENV_VARIABLE_CONFIG_PREFIX","exports","ConfigGetter","constructor","globalConfig","GlobalConfig","loadSync","store","_store","toPlainObject","addStore","currentStore","list","getConfig","key","undefined","envVarName","toEnvVariableName","process","env","val","isNil","gitKeys","includes","getFromGit","gitStore","gitVal","gitconfig","get","sync","getConfigNumeric","fromConfig","num","isNaN","Error","getConfigBoolean","result","listConfig","invalidateCache","getGlobalStore","set","del","delete","write","getPath","getGlobalConfigPath","configGetter","getNumberFromConfig","setGlobalConfig","globalStore","writeSync","catch","delGlobalConfig","configName","replace","toUpperCase"],"sources":["config-getter.ts"],"sourcesContent":["import gitconfig from '@teambit/gitconfig';\nimport { isNil } from 'lodash';\nimport { getGlobalConfigPath, GlobalConfig } from './global-config';\n\nexport const ENV_VARIABLE_CONFIG_PREFIX = 'BIT_CONFIG_';\n\nexport interface Store {\n list(): Record<string, string>;\n set(key: string, value: string): void;\n del(key: string): void;\n write(): Promise<void>;\n getPath(): string;\n invalidateCache(): Promise<void>;\n}\n\n/**\n * Singleton cache for the config object. so it can be used everywhere even by non-aspects components.\n */\nexport class ConfigGetter {\n private _store: Record<string, string> | undefined;\n private _globalConfig: GlobalConfig | undefined;\n private gitStore: Record<string, string | undefined> = {};\n\n get globalConfig() {\n if (!this._globalConfig) {\n this._globalConfig = GlobalConfig.loadSync();\n }\n return this._globalConfig;\n }\n\n get store() {\n if (!this._store) {\n this._store = this.globalConfig.toPlainObject();\n }\n return this._store;\n }\n\n /**\n * in case a config-key exists in both, the new one (the given store) wins.\n */\n addStore(store: Store) {\n const currentStore = this.store;\n this._store = { ...currentStore, ...store.list() };\n }\n\n getConfig(key: string): string | undefined {\n if (!key) {\n return undefined;\n }\n\n const envVarName = toEnvVariableName(key);\n if (process.env[envVarName]) {\n return process.env[envVarName];\n }\n\n const store = this.store;\n const val = store[key];\n if (!isNil(val)) {\n return val;\n }\n const gitKeys = ['user.name', 'user.email'];\n if (gitKeys.includes(key)) {\n return this.getFromGit(key);\n }\n }\n private getFromGit(key: string): string | undefined {\n if (key in this.gitStore) {\n return this.gitStore[key];\n }\n try {\n const gitVal = gitconfig.get.sync(key);\n this.gitStore[key] = gitVal;\n } catch {\n // Ignore error from git config get\n this.gitStore[key] = undefined;\n }\n return this.gitStore[key];\n }\n getConfigNumeric(key: string): number | undefined {\n const fromConfig = this.getConfig(key);\n if (isNil(fromConfig)) return undefined;\n const num = Number(fromConfig);\n if (Number.isNaN(num)) {\n throw new Error(`config of \"${key}\" is invalid. Expected number, got \"${fromConfig}\"`);\n }\n return num;\n }\n getConfigBoolean(key: string): boolean | undefined {\n const result = this.getConfig(key);\n if (isNil(result)) return undefined;\n if (typeof result === 'boolean') return result;\n if (result === 'true') return true;\n if (result === 'false') return false;\n throw new Error(`the configuration \"${key}\" has an invalid value \"${result}\". it should be boolean`);\n }\n listConfig() {\n const store = this.store;\n return store;\n }\n invalidateCache() {\n this._store = undefined;\n }\n getGlobalStore(): Store {\n return {\n list: () => this.globalConfig.toPlainObject(),\n set: (key: string, value: string) => this.globalConfig.set(key, value),\n del: (key: string) => this.globalConfig.delete(key),\n write: async () => this.globalConfig.write(),\n invalidateCache: async () => this._globalConfig = undefined,\n getPath: () => getGlobalConfigPath(),\n };\n }\n}\n\nexport const configGetter = new ConfigGetter();\n\nexport function getConfig(key: string): string | undefined {\n return configGetter.getConfig(key);\n}\nexport function getNumberFromConfig(key: string): number | undefined {\n return configGetter.getConfigNumeric(key);\n}\nexport function listConfig(): Record<string, string> {\n return configGetter.listConfig();\n}\n/**\n * @deprecated use setConfig from the ConfigStore aspect instance\n */\nexport function setGlobalConfig(key: string, val: string) {\n const globalStore = configGetter.getGlobalStore();\n globalStore.set(key, val);\n configGetter.globalConfig.writeSync();\n globalStore.invalidateCache().catch(() => {});\n configGetter.invalidateCache();\n}\n/**\n * @deprecated use delConfig from the ConfigStore aspect instance\n */\nexport function delGlobalConfig(key: string) {\n const globalStore = configGetter.getGlobalStore();\n globalStore.del(key);\n configGetter.globalConfig.writeSync();\n globalStore.invalidateCache().catch(() => {});\n configGetter.invalidateCache();\n}\n\nfunction toEnvVariableName(configName: string): string {\n return `${ENV_VARIABLE_CONFIG_PREFIX}${configName.replace(/\\./g, '_').toUpperCase()}`;\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;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AAC,CAAC;AAChC;AACA;AACA;AACA;AACO,SAASc,eAAeA,CAACtC,GAAW,EAAE;EAC3C,MAAMmC,WAAW,GAAGH,YAAY,CAACP,cAAc,CAAC,CAAC;EACjDU,WAAW,CAACR,GAAG,CAAC3B,GAAG,CAAC;EACpBgC,YAAY,CAAC1C,YAAY,CAAC8C,SAAS,CAAC,CAAC;EACrCD,WAAW,CAACX,eAAe,CAAC,CAAC,CAACa,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;EAC7CL,YAAY,CAACR,eAAe,CAAC,CAAC;AAChC;AAEA,SAASrB,iBAAiBA,CAACoC,UAAkB,EAAU;EACrD,OAAO,GAAGrD,0BAA0B,GAAGqD,UAAU,CAACC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAACC,WAAW,CAAC,CAAC,EAAE;AACvF","ignoreList":[]}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.ConfigStoreAspect = void 0;
|
7
|
+
function _harmony() {
|
8
|
+
const data = require("@teambit/harmony");
|
9
|
+
_harmony = function () {
|
10
|
+
return data;
|
11
|
+
};
|
12
|
+
return data;
|
13
|
+
}
|
14
|
+
const ConfigStoreAspect = exports.ConfigStoreAspect = _harmony().Aspect.create({
|
15
|
+
id: 'teambit.harmony/config-store'
|
16
|
+
});
|
17
|
+
|
18
|
+
//# sourceMappingURL=config-store.aspect.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_harmony","data","require","ConfigStoreAspect","exports","Aspect","create","id"],"sources":["config-store.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const ConfigStoreAspect = Aspect.create({\n id: 'teambit.harmony/config-store',\n});\n "],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EAC7CC,EAAE,EAAE;AACN,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { CLIMain } from '@teambit/cli';
|
2
|
+
import { Store } from './config-getter';
|
3
|
+
export type StoreOrigin = 'scope' | 'workspace' | 'global';
|
4
|
+
export declare class ConfigStoreMain {
|
5
|
+
private _stores;
|
6
|
+
get stores(): {
|
7
|
+
[origin: string]: Store;
|
8
|
+
};
|
9
|
+
addStore(origin: StoreOrigin, store: Store): void;
|
10
|
+
/**
|
11
|
+
* "global" must be first. the rest doesn't matter. can be scope or workspace.
|
12
|
+
*/
|
13
|
+
getStoresOrdered(): Store[];
|
14
|
+
invalidateCache(): void;
|
15
|
+
invalidateAllStoresCaches(): Promise<void>;
|
16
|
+
setConfig(key: string, value: string, origin?: StoreOrigin): Promise<void>;
|
17
|
+
getConfig(key: string): string | undefined;
|
18
|
+
getConfigBoolean(key: string): boolean | undefined;
|
19
|
+
getConfigNumeric(key: string): number | undefined;
|
20
|
+
delConfig(key: string, origin?: StoreOrigin): Promise<void>;
|
21
|
+
listConfig(): Record<string, string>;
|
22
|
+
static slots: never[];
|
23
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
24
|
+
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
25
|
+
static provider([cli]: [CLIMain]): Promise<ConfigStoreMain>;
|
26
|
+
}
|
27
|
+
export default ConfigStoreMain;
|
@@ -0,0 +1,127 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = exports.ConfigStoreMain = void 0;
|
7
|
+
function _cli() {
|
8
|
+
const data = require("@teambit/cli");
|
9
|
+
_cli = function () {
|
10
|
+
return data;
|
11
|
+
};
|
12
|
+
return data;
|
13
|
+
}
|
14
|
+
function _lodash() {
|
15
|
+
const data = require("lodash");
|
16
|
+
_lodash = function () {
|
17
|
+
return data;
|
18
|
+
};
|
19
|
+
return data;
|
20
|
+
}
|
21
|
+
function _configStore() {
|
22
|
+
const data = require("./config-store.aspect");
|
23
|
+
_configStore = function () {
|
24
|
+
return data;
|
25
|
+
};
|
26
|
+
return data;
|
27
|
+
}
|
28
|
+
function _configGetter() {
|
29
|
+
const data = require("./config-getter");
|
30
|
+
_configGetter = function () {
|
31
|
+
return data;
|
32
|
+
};
|
33
|
+
return data;
|
34
|
+
}
|
35
|
+
function _configCmd() {
|
36
|
+
const data = require("./config-cmd");
|
37
|
+
_configCmd = function () {
|
38
|
+
return data;
|
39
|
+
};
|
40
|
+
return data;
|
41
|
+
}
|
42
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
43
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
44
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
45
|
+
class ConfigStoreMain {
|
46
|
+
constructor() {
|
47
|
+
_defineProperty(this, "_stores", void 0);
|
48
|
+
}
|
49
|
+
get stores() {
|
50
|
+
if (!this._stores) {
|
51
|
+
this._stores = {
|
52
|
+
global: _configGetter().configGetter.getGlobalStore()
|
53
|
+
};
|
54
|
+
}
|
55
|
+
return this._stores;
|
56
|
+
}
|
57
|
+
addStore(origin, store) {
|
58
|
+
this.stores[origin] = store;
|
59
|
+
_configGetter().configGetter.addStore(store);
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* "global" must be first. the rest doesn't matter. can be scope or workspace.
|
63
|
+
*/
|
64
|
+
getStoresOrdered() {
|
65
|
+
return (0, _lodash().compact)([this.stores.global, this.stores.workspace, this.stores.scope].filter(Boolean));
|
66
|
+
}
|
67
|
+
invalidateCache() {
|
68
|
+
_configGetter().configGetter.invalidateCache();
|
69
|
+
const stores = this.getStoresOrdered();
|
70
|
+
stores.forEach(store => {
|
71
|
+
_configGetter().configGetter.addStore(store);
|
72
|
+
});
|
73
|
+
}
|
74
|
+
async invalidateAllStoresCaches() {
|
75
|
+
_configGetter().configGetter.invalidateCache();
|
76
|
+
const stores = this.getStoresOrdered();
|
77
|
+
for await (const store of stores) {
|
78
|
+
await store.invalidateCache();
|
79
|
+
_configGetter().configGetter.addStore(store);
|
80
|
+
}
|
81
|
+
;
|
82
|
+
}
|
83
|
+
async setConfig(key, value, origin = 'global') {
|
84
|
+
const store = this.stores[origin];
|
85
|
+
if (!store) throw new Error(`unable to set config, "${origin}" origin is missing`);
|
86
|
+
store.set(key, value);
|
87
|
+
await store.write();
|
88
|
+
await this.invalidateCache();
|
89
|
+
}
|
90
|
+
getConfig(key) {
|
91
|
+
return _configGetter().configGetter.getConfig(key);
|
92
|
+
}
|
93
|
+
getConfigBoolean(key) {
|
94
|
+
return _configGetter().configGetter.getConfigBoolean(key);
|
95
|
+
}
|
96
|
+
getConfigNumeric(key) {
|
97
|
+
return _configGetter().configGetter.getConfigNumeric(key);
|
98
|
+
}
|
99
|
+
async delConfig(key, origin) {
|
100
|
+
const getOrigin = () => {
|
101
|
+
if (origin) return origin;
|
102
|
+
return Object.keys(this.stores).find(originName => key in this.stores[originName].list());
|
103
|
+
};
|
104
|
+
const foundOrigin = getOrigin();
|
105
|
+
if (!foundOrigin) return; // if the key is not found in any store (or given store), nothing to do.
|
106
|
+
const store = this.stores[foundOrigin];
|
107
|
+
store.del(key);
|
108
|
+
await store.write();
|
109
|
+
await this.invalidateCache();
|
110
|
+
}
|
111
|
+
listConfig() {
|
112
|
+
return _configGetter().configGetter.listConfig();
|
113
|
+
}
|
114
|
+
static async provider([cli]) {
|
115
|
+
const configStore = new ConfigStoreMain();
|
116
|
+
cli.register(new (_configCmd().ConfigCmd)(configStore));
|
117
|
+
return configStore;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
exports.ConfigStoreMain = ConfigStoreMain;
|
121
|
+
_defineProperty(ConfigStoreMain, "slots", []);
|
122
|
+
_defineProperty(ConfigStoreMain, "dependencies", [_cli().CLIAspect]);
|
123
|
+
_defineProperty(ConfigStoreMain, "runtime", _cli().MainRuntime);
|
124
|
+
_configStore().ConfigStoreAspect.addRuntime(ConfigStoreMain);
|
125
|
+
var _default = exports.default = ConfigStoreMain;
|
126
|
+
|
127
|
+
//# sourceMappingURL=config-store.main.runtime.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_lodash","_configStore","_configGetter","_configCmd","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ConfigStoreMain","constructor","stores","_stores","global","configGetter","getGlobalStore","addStore","origin","store","getStoresOrdered","compact","workspace","scope","filter","Boolean","invalidateCache","forEach","invalidateAllStoresCaches","setConfig","key","Error","set","write","getConfig","getConfigBoolean","getConfigNumeric","delConfig","getOrigin","keys","find","originName","list","foundOrigin","del","listConfig","provider","cli","configStore","register","ConfigCmd","exports","CLIAspect","MainRuntime","ConfigStoreAspect","addRuntime","_default","default"],"sources":["config-store.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { compact } from 'lodash';\nimport { ConfigStoreAspect } from './config-store.aspect';\nimport { configGetter, Store } from './config-getter';\nimport { ConfigCmd } from './config-cmd';\n\nexport type StoreOrigin = 'scope' | 'workspace' | 'global';\n\nexport class ConfigStoreMain {\n private _stores: { [origin: string]: Store } | undefined;\n get stores (): { [origin: string]: Store } {\n if (!this._stores) {\n this._stores = {\n global: configGetter.getGlobalStore()\n };\n }\n return this._stores;\n }\n addStore(origin: StoreOrigin, store: Store) {\n this.stores[origin] = store;\n configGetter.addStore(store);\n }\n /**\n * \"global\" must be first. the rest doesn't matter. can be scope or workspace.\n */\n getStoresOrdered(): Store[] {\n return compact([this.stores.global, this.stores.workspace, this.stores.scope].filter(Boolean)) as Store[];\n }\n invalidateCache() {\n configGetter.invalidateCache();\n const stores = this.getStoresOrdered();\n stores.forEach((store) => {\n configGetter.addStore(store);\n });\n }\n async invalidateAllStoresCaches() {\n configGetter.invalidateCache();\n const stores = this.getStoresOrdered();\n for await (const store of stores) {\n await store.invalidateCache();\n configGetter.addStore(store);\n };\n }\n async setConfig(key: string, value: string, origin: StoreOrigin = 'global') {\n const store = this.stores[origin];\n if (!store) throw new Error(`unable to set config, \"${origin}\" origin is missing`);\n store.set(key, value);\n await store.write();\n await this.invalidateCache();\n }\n getConfig(key: string): string | undefined {\n return configGetter.getConfig(key);\n }\n getConfigBoolean(key: string): boolean | undefined {\n return configGetter.getConfigBoolean(key);\n }\n getConfigNumeric(key: string): number | undefined {\n return configGetter.getConfigNumeric(key);\n }\n async delConfig(key: string, origin?: StoreOrigin) {\n const getOrigin = () => {\n if (origin) return origin;\n return Object.keys(this.stores).find(originName => key in this.stores[originName].list());\n }\n const foundOrigin = getOrigin();\n if (!foundOrigin) return; // if the key is not found in any store (or given store), nothing to do.\n const store = this.stores[foundOrigin];\n store.del(key);\n await store.write();\n await this.invalidateCache();\n }\n listConfig() {\n return configGetter.listConfig();\n }\n\n static slots = [];\n static dependencies = [CLIAspect];\n static runtime = MainRuntime;\n static async provider([cli]: [CLIMain]) {\n const configStore = new ConfigStoreMain();\n cli.register(new ConfigCmd(configStore));\n return configStore;\n\n }\n}\n\nConfigStoreAspect.addRuntime(ConfigStoreMain);\n\nexport default ConfigStoreMain;\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OA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e,CAAC,CAAC;EAC9B;EACAmB,UAAUA,CAAA,EAAG;IACX,OAAO9B,4BAAY,CAAC8B,UAAU,CAAC,CAAC;EAClC;EAKA,aAAaC,QAAQA,CAAC,CAACC,GAAG,CAAY,EAAE;IACtC,MAAMC,WAAW,GAAG,IAAItC,eAAe,CAAC,CAAC;IACzCqC,GAAG,CAACE,QAAQ,CAAC,KAAIC,sBAAS,EAACF,WAAW,CAAC,CAAC;IACxC,OAAOA,WAAW;EAEpB;AACF;AAACG,OAAA,CAAAzC,eAAA,GAAAA,eAAA;AAAAnB,eAAA,CA5EYmB,eAAe,WAmEX,EAAE;AAAAnB,eAAA,CAnENmB,eAAe,kBAoEJ,CAAC0C,gBAAS,CAAC;AAAA7D,eAAA,CApEtBmB,eAAe,aAqET2C,kBAAW;AAS9BC,gCAAiB,CAACC,UAAU,CAAC7C,eAAe,CAAC;AAAC,IAAA8C,QAAA,GAAAL,OAAA,CAAAM,OAAA,GAE/B/C,eAAe","ignoreList":[]}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export declare function getGlobalConfigPath(): string;
|
2
|
+
export declare class GlobalConfig extends Map<string, string> {
|
3
|
+
toPlainObject(): {
|
4
|
+
[key: string]: any;
|
5
|
+
};
|
6
|
+
toJson(): string;
|
7
|
+
write(): Promise<void>;
|
8
|
+
writeSync(): void;
|
9
|
+
static loadSync(): GlobalConfig;
|
10
|
+
static load(): Promise<GlobalConfig>;
|
11
|
+
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.GlobalConfig = void 0;
|
7
|
+
exports.getGlobalConfigPath = getGlobalConfigPath;
|
8
|
+
function _fsExtra() {
|
9
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
10
|
+
_fsExtra = function () {
|
11
|
+
return data;
|
12
|
+
};
|
13
|
+
return data;
|
14
|
+
}
|
15
|
+
function path() {
|
16
|
+
const data = _interopRequireWildcard(require("path"));
|
17
|
+
path = function () {
|
18
|
+
return data;
|
19
|
+
};
|
20
|
+
return data;
|
21
|
+
}
|
22
|
+
function _legacy() {
|
23
|
+
const data = require("@teambit/legacy.constants");
|
24
|
+
_legacy = function () {
|
25
|
+
return data;
|
26
|
+
};
|
27
|
+
return data;
|
28
|
+
}
|
29
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
30
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
31
|
+
function getGlobalConfigPath() {
|
32
|
+
return path().join(_legacy().GLOBAL_CONFIG, _legacy().GLOBAL_CONFIG_FILE);
|
33
|
+
}
|
34
|
+
class GlobalConfig extends Map {
|
35
|
+
toPlainObject() {
|
36
|
+
return mapToObject(this);
|
37
|
+
}
|
38
|
+
toJson() {
|
39
|
+
return JSON.stringify(this.toPlainObject(), null, 2);
|
40
|
+
}
|
41
|
+
write() {
|
42
|
+
return _fsExtra().default.outputFile(getGlobalConfigPath(), this.toJson());
|
43
|
+
}
|
44
|
+
writeSync() {
|
45
|
+
return _fsExtra().default.outputFileSync(getGlobalConfigPath(), this.toJson());
|
46
|
+
}
|
47
|
+
static loadSync() {
|
48
|
+
const configPath = getGlobalConfigPath();
|
49
|
+
if (!_fsExtra().default.existsSync(configPath)) {
|
50
|
+
const config = new GlobalConfig([]);
|
51
|
+
config.writeSync();
|
52
|
+
return config;
|
53
|
+
}
|
54
|
+
const contents = _fsExtra().default.readFileSync(configPath);
|
55
|
+
return new GlobalConfig(Object.entries(JSON.parse(contents.toString())));
|
56
|
+
}
|
57
|
+
static async load() {
|
58
|
+
const configPath = getGlobalConfigPath();
|
59
|
+
const exists = await _fsExtra().default.pathExists(configPath);
|
60
|
+
if (!exists) {
|
61
|
+
const config = new GlobalConfig([]);
|
62
|
+
await config.write();
|
63
|
+
return config;
|
64
|
+
}
|
65
|
+
const contents = await _fsExtra().default.readFile(configPath);
|
66
|
+
return new GlobalConfig(Object.entries(JSON.parse(contents.toString())));
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Cast a `Map` to a plain object.
|
72
|
+
* Keys are being casted by invoking `toString` on each key.
|
73
|
+
* @name mapToObject
|
74
|
+
* @param {Map} map to cast
|
75
|
+
* @returns {*} plain object
|
76
|
+
* @example
|
77
|
+
* ```js
|
78
|
+
* mapToObject(new Map([['key', 'val'], ['foo', 'bar']]));
|
79
|
+
* // => { key: 'val', foo: 'bar' }
|
80
|
+
* ```
|
81
|
+
*/
|
82
|
+
exports.GlobalConfig = GlobalConfig;
|
83
|
+
function mapToObject(map) {
|
84
|
+
const object = {};
|
85
|
+
map.forEach((val, key) => {
|
86
|
+
object[key.toString()] = val;
|
87
|
+
});
|
88
|
+
return object;
|
89
|
+
}
|
90
|
+
|
91
|
+
//# sourceMappingURL=global-config.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","path","_interopRequireWildcard","_legacy","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","getGlobalConfigPath","join","GLOBAL_CONFIG","GLOBAL_CONFIG_FILE","GlobalConfig","Map","toPlainObject","mapToObject","toJson","JSON","stringify","write","fs","outputFile","writeSync","outputFileSync","loadSync","configPath","existsSync","config","contents","readFileSync","entries","parse","toString","load","exists","pathExists","readFile","exports","map","object","forEach","val","key"],"sources":["global-config.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport * as path from 'path';\n\nimport { GLOBAL_CONFIG, GLOBAL_CONFIG_FILE } from '@teambit/legacy.constants';\n\nexport function getGlobalConfigPath() {\n return path.join(GLOBAL_CONFIG, GLOBAL_CONFIG_FILE);\n}\n\nexport class GlobalConfig extends Map<string, string> {\n toPlainObject() {\n return mapToObject(this);\n }\n\n toJson() {\n return JSON.stringify(this.toPlainObject(), null, 2);\n }\n\n write() {\n return fs.outputFile(getGlobalConfigPath(), this.toJson());\n }\n\n writeSync() {\n return fs.outputFileSync(getGlobalConfigPath(), this.toJson());\n }\n\n static loadSync(): GlobalConfig {\n const configPath = getGlobalConfigPath();\n if (!fs.existsSync(configPath)) {\n const config = new GlobalConfig([]);\n config.writeSync();\n return config;\n }\n const contents = fs.readFileSync(configPath);\n return new GlobalConfig(Object.entries(JSON.parse(contents.toString())));\n }\n\n static async load(): Promise<GlobalConfig> {\n const configPath = getGlobalConfigPath();\n const exists = await fs.pathExists(configPath);\n if (!exists) {\n const config = new GlobalConfig([]);\n await config.write();\n return config;\n }\n const contents = await fs.readFile(configPath);\n return new GlobalConfig(Object.entries(JSON.parse(contents.toString())));\n }\n}\n\n/**\n * Cast a `Map` to a plain object.\n * Keys are being casted by invoking `toString` on each key.\n * @name mapToObject\n * @param {Map} map to cast\n * @returns {*} plain object\n * @example\n * ```js\n * mapToObject(new Map([['key', 'val'], ['foo', 'bar']]));\n * // => { key: 'val', foo: 'bar' }\n * ```\n */\nfunction mapToObject(map: Map<any, any>): { [key: string]: any } {\n const object = {};\n map.forEach((val, key) => {\n object[key.toString()] = val;\n });\n return object;\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAI,uB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C,MAAM0B,MAAM,GAAG,MAAMd,kBAAE,CAACe,UAAU,CAACV,UAAU,CAAC;IAC9C,IAAI,CAACS,MAAM,EAAE;MACX,MAAMP,MAAM,GAAG,IAAIf,YAAY,CAAC,EAAE,CAAC;MACnC,MAAMe,MAAM,CAACR,KAAK,CAAC,CAAC;MACpB,OAAOQ,MAAM;IACf;IACA,MAAMC,QAAQ,GAAG,MAAMR,kBAAE,CAACgB,QAAQ,CAACX,UAAU,CAAC;IAC9C,OAAO,IAAIb,YAAY,CAACP,MAAM,CAACyB,OAAO,CAACb,IAAI,CAACc,KAAK,CAACH,QAAQ,CAACI,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;EAC1E;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAXAK,OAAA,CAAAzB,YAAA,GAAAA,YAAA;AAYA,SAASG,WAAWA,CAACuB,GAAkB,EAA0B;EAC/D,MAAMC,MAAM,GAAG,CAAC,CAAC;EACjBD,GAAG,CAACE,OAAO,CAAC,CAACC,GAAG,EAAEC,GAAG,KAAK;IACxBH,MAAM,CAACG,GAAG,CAACV,QAAQ,CAAC,CAAC,CAAC,GAAGS,GAAG;EAC9B,CAAC,CAAC;EACF,OAAOF,MAAM;AACf","ignoreList":[]}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ConfigStoreAspect } from './config-store.aspect';
|
2
|
+
export type { ConfigStoreMain } from './config-store.main.runtime';
|
3
|
+
export default ConfigStoreAspect;
|
4
|
+
export { ConfigStoreAspect };
|
5
|
+
export { getConfig, getNumberFromConfig, listConfig, Store, setGlobalConfig, delGlobalConfig } from './config-getter';
|
package/dist/index.js
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "ConfigStoreAspect", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function () {
|
9
|
+
return _configStore().ConfigStoreAspect;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
Object.defineProperty(exports, "Store", {
|
13
|
+
enumerable: true,
|
14
|
+
get: function () {
|
15
|
+
return _configGetter().Store;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
exports.default = void 0;
|
19
|
+
Object.defineProperty(exports, "delGlobalConfig", {
|
20
|
+
enumerable: true,
|
21
|
+
get: function () {
|
22
|
+
return _configGetter().delGlobalConfig;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
Object.defineProperty(exports, "getConfig", {
|
26
|
+
enumerable: true,
|
27
|
+
get: function () {
|
28
|
+
return _configGetter().getConfig;
|
29
|
+
}
|
30
|
+
});
|
31
|
+
Object.defineProperty(exports, "getNumberFromConfig", {
|
32
|
+
enumerable: true,
|
33
|
+
get: function () {
|
34
|
+
return _configGetter().getNumberFromConfig;
|
35
|
+
}
|
36
|
+
});
|
37
|
+
Object.defineProperty(exports, "listConfig", {
|
38
|
+
enumerable: true,
|
39
|
+
get: function () {
|
40
|
+
return _configGetter().listConfig;
|
41
|
+
}
|
42
|
+
});
|
43
|
+
Object.defineProperty(exports, "setGlobalConfig", {
|
44
|
+
enumerable: true,
|
45
|
+
get: function () {
|
46
|
+
return _configGetter().setGlobalConfig;
|
47
|
+
}
|
48
|
+
});
|
49
|
+
function _configStore() {
|
50
|
+
const data = require("./config-store.aspect");
|
51
|
+
_configStore = function () {
|
52
|
+
return data;
|
53
|
+
};
|
54
|
+
return data;
|
55
|
+
}
|
56
|
+
function _configGetter() {
|
57
|
+
const data = require("./config-getter");
|
58
|
+
_configGetter = function () {
|
59
|
+
return data;
|
60
|
+
};
|
61
|
+
return data;
|
62
|
+
}
|
63
|
+
var _default = exports.default = _configStore().ConfigStoreAspect;
|
64
|
+
|
65
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_configStore","data","require","_configGetter","_default","exports","default","ConfigStoreAspect"],"sources":["index.ts"],"sourcesContent":["import { ConfigStoreAspect } from './config-store.aspect';\n\nexport type { ConfigStoreMain } from './config-store.main.runtime';\nexport default ConfigStoreAspect;\nexport { ConfigStoreAspect };\nexport { getConfig, getNumberFromConfig, listConfig, Store, setGlobalConfig, delGlobalConfig } from './config-getter';"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAE,cAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAsH,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAFvGC,gCAAiB","ignoreList":[]}
|
package/package.json
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
{
|
2
|
+
"name": "@teambit/config-store",
|
3
|
+
"version": "0.0.0-0a1c5597b19267cf5009b21ff79d851ae9310c7a",
|
4
|
+
"homepage": "https://bit.cloud/teambit/harmony/config-store",
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"componentId": {
|
7
|
+
"scope": "teambit.harmony",
|
8
|
+
"name": "config-store",
|
9
|
+
"version": "0a1c5597b19267cf5009b21ff79d851ae9310c7a"
|
10
|
+
},
|
11
|
+
"dependencies": {
|
12
|
+
"chalk": "4.1.2",
|
13
|
+
"pad-right": "0.2.2",
|
14
|
+
"@teambit/gitconfig": "2.0.10",
|
15
|
+
"lodash": "4.17.21",
|
16
|
+
"fs-extra": "10.0.0",
|
17
|
+
"@teambit/harmony": "0.4.7",
|
18
|
+
"@teambit/cli": "0.0.0-488f076a7c57433b94373d42c763e18868925950",
|
19
|
+
"@teambit/legacy.constants": "0.0.12"
|
20
|
+
},
|
21
|
+
"devDependencies": {
|
22
|
+
"@types/lodash": "4.14.165",
|
23
|
+
"@types/fs-extra": "9.0.7",
|
24
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.69"
|
25
|
+
},
|
26
|
+
"peerDependencies": {},
|
27
|
+
"license": "Apache-2.0",
|
28
|
+
"optionalDependencies": {},
|
29
|
+
"peerDependenciesMeta": {},
|
30
|
+
"exports": {
|
31
|
+
".": {
|
32
|
+
"node": {
|
33
|
+
"require": "./dist/index.js",
|
34
|
+
"import": "./dist/esm.mjs"
|
35
|
+
},
|
36
|
+
"default": "./dist/index.js"
|
37
|
+
},
|
38
|
+
"./dist/*": "./dist/*",
|
39
|
+
"./artifacts/*": "./artifacts/*",
|
40
|
+
"./*": "./*.ts"
|
41
|
+
},
|
42
|
+
"private": false,
|
43
|
+
"engines": {
|
44
|
+
"node": ">=16.0.0"
|
45
|
+
},
|
46
|
+
"repository": {
|
47
|
+
"type": "git",
|
48
|
+
"url": "https://github.com/teambit/bit"
|
49
|
+
},
|
50
|
+
"keywords": [
|
51
|
+
"bit",
|
52
|
+
"bit-aspect",
|
53
|
+
"bit-core-aspect",
|
54
|
+
"components",
|
55
|
+
"collaboration",
|
56
|
+
"web"
|
57
|
+
]
|
58
|
+
}
|
package/types/asset.d.ts
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
declare module '*.png' {
|
2
|
+
const value: any;
|
3
|
+
export = value;
|
4
|
+
}
|
5
|
+
declare module '*.svg' {
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
7
|
+
|
8
|
+
export const ReactComponent: FunctionComponent<
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
10
|
+
>;
|
11
|
+
const src: string;
|
12
|
+
export default src;
|
13
|
+
}
|
14
|
+
declare module '*.jpg' {
|
15
|
+
const value: any;
|
16
|
+
export = value;
|
17
|
+
}
|
18
|
+
declare module '*.jpeg' {
|
19
|
+
const value: any;
|
20
|
+
export = value;
|
21
|
+
}
|
22
|
+
declare module '*.gif' {
|
23
|
+
const value: any;
|
24
|
+
export = value;
|
25
|
+
}
|
26
|
+
declare module '*.bmp' {
|
27
|
+
const value: any;
|
28
|
+
export = value;
|
29
|
+
}
|
30
|
+
declare module '*.otf' {
|
31
|
+
const value: any;
|
32
|
+
export = value;
|
33
|
+
}
|
34
|
+
declare module '*.woff' {
|
35
|
+
const value: any;
|
36
|
+
export = value;
|
37
|
+
}
|
38
|
+
declare module '*.woff2' {
|
39
|
+
const value: any;
|
40
|
+
export = value;
|
41
|
+
}
|
package/types/style.d.ts
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
declare module '*.module.css' {
|
2
|
+
const classes: { readonly [key: string]: string };
|
3
|
+
export default classes;
|
4
|
+
}
|
5
|
+
declare module '*.module.scss' {
|
6
|
+
const classes: { readonly [key: string]: string };
|
7
|
+
export default classes;
|
8
|
+
}
|
9
|
+
declare module '*.module.sass' {
|
10
|
+
const classes: { readonly [key: string]: string };
|
11
|
+
export default classes;
|
12
|
+
}
|
13
|
+
|
14
|
+
declare module '*.module.less' {
|
15
|
+
const classes: { readonly [key: string]: string };
|
16
|
+
export default classes;
|
17
|
+
}
|
18
|
+
|
19
|
+
declare module '*.less' {
|
20
|
+
const classes: { readonly [key: string]: string };
|
21
|
+
export default classes;
|
22
|
+
}
|
23
|
+
|
24
|
+
declare module '*.css' {
|
25
|
+
const classes: { readonly [key: string]: string };
|
26
|
+
export default classes;
|
27
|
+
}
|
28
|
+
|
29
|
+
declare module '*.sass' {
|
30
|
+
const classes: { readonly [key: string]: string };
|
31
|
+
export default classes;
|
32
|
+
}
|
33
|
+
|
34
|
+
declare module '*.scss' {
|
35
|
+
const classes: { readonly [key: string]: string };
|
36
|
+
export default classes;
|
37
|
+
}
|
38
|
+
|
39
|
+
declare module '*.mdx' {
|
40
|
+
const component: any;
|
41
|
+
export default component;
|
42
|
+
}
|