@dxos/config 0.8.3 → 0.8.4-main.1da679c
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/lib/browser/index.mjs +28 -14
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +51 -27
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/plugin/node-esm/{chunk-PAFU3TJI.mjs → chunk-KVRVDEOZ.mjs} +45 -21
- package/dist/plugin/node-esm/chunk-KVRVDEOZ.mjs.map +7 -0
- package/dist/plugin/node-esm/esbuild-plugin.mjs +4 -3
- package/dist/plugin/node-esm/esbuild-plugin.mjs.map +1 -1
- package/dist/plugin/node-esm/meta.json +1 -1
- package/dist/plugin/node-esm/rollup-plugin.mjs +2 -2
- package/dist/plugin/node-esm/vite-plugin.mjs +6 -6
- package/dist/plugin/node-esm/vite-plugin.mjs.map +3 -3
- package/dist/types/src/loaders/index.d.ts.map +1 -1
- package/dist/types/src/plugin/definitions.d.ts +3 -3
- package/dist/types/src/plugin/definitions.d.ts.map +1 -1
- package/dist/types/src/plugin/index.d.ts +1 -1
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/types.d.ts +4 -0
- package/dist/types/src/plugin/types.d.ts.map +1 -1
- package/dist/types/src/plugin/vite-plugin.d.ts +1 -1
- package/dist/types/src/plugin/vite-plugin.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -6
- package/src/loaders/index.ts +2 -1
- package/src/plugin/definitions.ts +7 -5
- package/src/plugin/index.ts +1 -1
- package/src/plugin/types.ts +5 -0
- package/src/plugin/vite-plugin.ts +9 -5
- package/src/testing/build.js +1 -1
- package/README.yml +0 -1
- package/dist/lib/node/index.cjs +0 -357
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/plugin/node/chunk-SLXRWZWZ.cjs +0 -249
- package/dist/plugin/node/chunk-SLXRWZWZ.cjs.map +0 -7
- package/dist/plugin/node/esbuild-plugin.cjs +0 -45
- package/dist/plugin/node/esbuild-plugin.cjs.map +0 -7
- package/dist/plugin/node/meta.json +0 -1
- package/dist/plugin/node/rollup-plugin.cjs +0 -39
- package/dist/plugin/node/rollup-plugin.cjs.map +0 -7
- package/dist/plugin/node/vite-plugin.cjs +0 -50
- package/dist/plugin/node/vite-plugin.cjs.map +0 -7
- package/dist/plugin/node-esm/chunk-PAFU3TJI.mjs.map +0 -7
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
import yaml from "js-yaml";
|
|
3
|
+
// src/plugin/definitions.ts
|
|
5
4
|
import { execSync } from "node:child_process";
|
|
6
5
|
import { readFileSync } from "node:fs";
|
|
7
6
|
import { resolve } from "node:path";
|
|
7
|
+
import yaml from "js-yaml";
|
|
8
8
|
import pkgUp from "pkg-up";
|
|
9
|
+
import { invariant } from "@dxos/invariant";
|
|
9
10
|
import { log } from "@dxos/log";
|
|
10
11
|
import { setDeep as setDeep2 } from "@dxos/util";
|
|
11
12
|
|
|
12
|
-
//
|
|
13
|
+
// src/config.ts
|
|
13
14
|
import { boolean } from "boolean";
|
|
14
15
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
15
16
|
import isMatch from "lodash.ismatch";
|
|
@@ -17,6 +18,19 @@ import { InvalidConfigError } from "@dxos/protocols";
|
|
|
17
18
|
import { schema } from "@dxos/protocols/proto";
|
|
18
19
|
import { trace } from "@dxos/tracing";
|
|
19
20
|
import { getDeep, setDeep } from "@dxos/util";
|
|
21
|
+
function _define_property(obj, key, value) {
|
|
22
|
+
if (key in obj) {
|
|
23
|
+
Object.defineProperty(obj, key, {
|
|
24
|
+
value,
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
obj[key] = value;
|
|
31
|
+
}
|
|
32
|
+
return obj;
|
|
33
|
+
}
|
|
20
34
|
function _ts_decorate(decorators, target, key, desc) {
|
|
21
35
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22
36
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -71,15 +85,6 @@ var validateConfig = (config) => {
|
|
|
71
85
|
};
|
|
72
86
|
var ConfigResource = Symbol.for("dxos.resource.Config");
|
|
73
87
|
var Config = class {
|
|
74
|
-
/**
|
|
75
|
-
* Creates an immutable instance.
|
|
76
|
-
* @constructor
|
|
77
|
-
*/
|
|
78
|
-
constructor(config = {}, ...objects) {
|
|
79
|
-
this._config = validateConfig(defaultsDeep(config, ...objects, {
|
|
80
|
-
version: 1
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
88
|
/**
|
|
84
89
|
* Returns an immutable config JSON object.
|
|
85
90
|
*/
|
|
@@ -118,6 +123,16 @@ var Config = class {
|
|
|
118
123
|
}
|
|
119
124
|
return value;
|
|
120
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates an immutable instance.
|
|
128
|
+
* @constructor
|
|
129
|
+
*/
|
|
130
|
+
constructor(config = {}, ...objects) {
|
|
131
|
+
_define_property(this, "_config", void 0);
|
|
132
|
+
this._config = validateConfig(defaultsDeep(config, ...objects, {
|
|
133
|
+
version: 1
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
121
136
|
};
|
|
122
137
|
Config = _ts_decorate([
|
|
123
138
|
trace.resource({
|
|
@@ -125,8 +140,8 @@ Config = _ts_decorate([
|
|
|
125
140
|
})
|
|
126
141
|
], Config);
|
|
127
142
|
|
|
128
|
-
//
|
|
129
|
-
var __dxlog_file = "/
|
|
143
|
+
// src/plugin/definitions.ts
|
|
144
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/config/src/plugin/definitions.ts";
|
|
130
145
|
var CWD = process.cwd();
|
|
131
146
|
var definitions = ({ configPath, envPath, devPath, mode = process.env.NODE_ENV, publicUrl = "", env }) => {
|
|
132
147
|
const KEYS_TO_FILE = {
|
|
@@ -137,6 +152,15 @@ var definitions = ({ configPath, envPath, devPath, mode = process.env.NODE_ENV,
|
|
|
137
152
|
KEYS_TO_FILE.__CONFIG_LOCAL__ = devPath ?? resolve(CWD, "dx-local.yml");
|
|
138
153
|
}
|
|
139
154
|
return Object.entries(KEYS_TO_FILE).reduce((prev, [key, value]) => {
|
|
155
|
+
invariant(key, void 0, {
|
|
156
|
+
F: __dxlog_file,
|
|
157
|
+
L: 40,
|
|
158
|
+
S: void 0,
|
|
159
|
+
A: [
|
|
160
|
+
"key",
|
|
161
|
+
""
|
|
162
|
+
]
|
|
163
|
+
});
|
|
140
164
|
let content = {};
|
|
141
165
|
try {
|
|
142
166
|
content = yaml.load(readFileSync(value, "utf-8"));
|
|
@@ -186,14 +210,14 @@ var definitions = ({ configPath, envPath, devPath, mode = process.env.NODE_ENV,
|
|
|
186
210
|
if (err.message.includes("YAMLException")) {
|
|
187
211
|
log.error(`Failed to parse file ${value}:`, err, {
|
|
188
212
|
F: __dxlog_file,
|
|
189
|
-
L:
|
|
213
|
+
L: 73,
|
|
190
214
|
S: void 0,
|
|
191
215
|
C: (f, a) => f(...a)
|
|
192
216
|
});
|
|
193
217
|
} else {
|
|
194
218
|
log(`Failed to load file ${value}:`, err, {
|
|
195
219
|
F: __dxlog_file,
|
|
196
|
-
L:
|
|
220
|
+
L: 75,
|
|
197
221
|
S: void 0,
|
|
198
222
|
C: (f, a) => f(...a)
|
|
199
223
|
});
|
|
@@ -207,17 +231,17 @@ var definitions = ({ configPath, envPath, devPath, mode = process.env.NODE_ENV,
|
|
|
207
231
|
[key]: content
|
|
208
232
|
};
|
|
209
233
|
}, {
|
|
234
|
+
__CONFIG_DEFAULTS__: {},
|
|
235
|
+
__CONFIG_ENVS__: {},
|
|
236
|
+
__CONFIG_LOCAL__: {},
|
|
210
237
|
__DXOS_CONFIG__: {
|
|
211
238
|
dynamic: mode === "production",
|
|
212
239
|
publicUrl
|
|
213
|
-
}
|
|
214
|
-
__CONFIG_DEFAULTS__: {},
|
|
215
|
-
__CONFIG_ENVS__: {},
|
|
216
|
-
__CONFIG_LOCAL__: {}
|
|
240
|
+
}
|
|
217
241
|
});
|
|
218
242
|
};
|
|
219
243
|
|
|
220
244
|
export {
|
|
221
245
|
definitions
|
|
222
246
|
};
|
|
223
|
-
//# sourceMappingURL=chunk-
|
|
247
|
+
//# sourceMappingURL=chunk-KVRVDEOZ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugin/definitions.ts", "../../../src/config.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { execSync } from 'node:child_process';\nimport { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\nimport yaml from 'js-yaml';\nimport pkgUp from 'pkg-up';\n\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { setDeep } from '@dxos/util';\n\nimport { mapFromKeyValues } from '../config';\n\nimport { type ConfigPluginOpts } from './types';\n\nconst CWD = process.cwd();\n\nexport const definitions = ({\n configPath,\n envPath,\n devPath,\n mode = process.env.NODE_ENV,\n publicUrl = '',\n env,\n}: ConfigPluginOpts) => {\n const KEYS_TO_FILE = {\n __CONFIG_DEFAULTS__: configPath?.length ? configPath : resolve(CWD, 'dx.yml'),\n __CONFIG_ENVS__: envPath?.length ? envPath : resolve(CWD, 'dx-env.yml'),\n } as { [key: string]: string };\n if (mode !== 'production') {\n KEYS_TO_FILE.__CONFIG_LOCAL__ = devPath ?? resolve(CWD, 'dx-local.yml');\n }\n\n return Object.entries(KEYS_TO_FILE).reduce(\n (prev, [key, value]) => {\n invariant(key);\n let content = {};\n try {\n content = yaml.load(readFileSync(value, 'utf-8')) as any;\n\n // Map environment variables to config values.\n if (key === '__CONFIG_ENVS__') {\n content = mapFromKeyValues(content, process.env);\n }\n\n if (key === '__CONFIG_DEFAULTS__') {\n // Load app environment variables into default config.\n Object.entries(process.env).forEach(([key, value]) => {\n if (key.startsWith('DX_') || env?.includes(key)) {\n setDeep(content, ['runtime', 'app', 'env', key], value);\n }\n });\n\n // Set build info automatically if available.\n try {\n const timestamp = new Date().toISOString();\n const commitHash =\n process.env.DX_COMMIT_HASH ??\n execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).replace('\\n', '');\n const packagePath = pkgUp.sync();\n const packageJson = packagePath && JSON.parse(readFileSync(packagePath, 'utf-8'));\n setDeep(content, ['runtime', 'app', 'build', 'timestamp'], timestamp);\n setDeep(content, ['runtime', 'app', 'build', 'commitHash'], commitHash);\n setDeep(content, ['runtime', 'app', 'build', 'version'], packageJson?.version);\n } catch {}\n }\n } catch (err: any) {\n if (err.message.includes('YAMLException')) {\n log.error(`Failed to parse file ${value}:`, err);\n } else {\n log(`Failed to load file ${value}:`, err);\n }\n\n if (key === '__CONFIG_DEFAULTS__') {\n // Default config is required.\n throw new Error(`Failed to load default config file from ${value}`);\n }\n }\n\n return {\n ...prev,\n [key]: content,\n };\n },\n {\n __CONFIG_DEFAULTS__: {},\n __CONFIG_ENVS__: {},\n __CONFIG_LOCAL__: {},\n __DXOS_CONFIG__: { dynamic: mode === 'production', publicUrl },\n },\n );\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { boolean } from 'boolean';\nimport defaultsDeep from 'lodash.defaultsdeep';\nimport isMatch from 'lodash.ismatch';\n\nimport { InvalidConfigError } from '@dxos/protocols';\nimport { schema } from '@dxos/protocols/proto';\nimport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\nimport { trace } from '@dxos/tracing';\nimport { getDeep, setDeep } from '@dxos/util';\n\nimport { type ConfigKey, type DeepIndex, type ParseKey } from './types';\n\ntype MappingSpec = Record<string, { path: string; type?: string }>;\nconst configRootType = schema.getCodecForType('dxos.config.Config');\n\n/**\n * Maps the given objects onto a flattened set of (key x values).\n *\n * Expects parsed yaml content of the form:\n *\n * ```\n * ENV_VAR:\n * path: config.selector.path\n * ```\n *\n * @param {object} spec\n * @param {object} values\n * @return {object}\n */\nexport const mapFromKeyValues = (spec: MappingSpec, values: Record<string, any>) => {\n const config = {};\n\n for (const [key, { path, type }] of Object.entries(spec)) {\n let value = values[key];\n\n if (value !== undefined) {\n if (type) {\n switch (type) {\n case 'boolean': {\n value = boolean(value);\n break;\n }\n\n case 'number': {\n value = Number(value);\n break;\n }\n\n case 'string': {\n break;\n }\n\n case 'json': {\n value = value ? JSON.parse(value) : null;\n break;\n }\n\n default: {\n throw new Error(`Invalid type: ${type}`);\n }\n }\n }\n\n setDeep(config, path.split('.'), value);\n }\n }\n\n return config;\n};\n\n/**\n * Maps the given flattend set of (key x values) onto a JSON object.\n * @param {object} spec\n * @param {object} values\n */\nexport const mapToKeyValues = (spec: MappingSpec, values: any) => {\n const config: Record<string, any> = {};\n\n for (const [key, { path, type }] of Object.entries(spec)) {\n const value = getDeep(values, path.split('.'));\n if (value !== undefined) {\n switch (type) {\n case 'json':\n config[key] = JSON.stringify(value);\n break;\n default:\n config[key] = value;\n }\n }\n }\n\n return config;\n};\n\n/**\n * Validate config object.\n */\nexport const validateConfig = (config: ConfigProto): ConfigProto => {\n if (!('version' in config)) {\n throw new InvalidConfigError('Version not specified');\n }\n\n if (config?.version !== 1) {\n throw new InvalidConfigError(`Invalid config version: ${config.version}`);\n }\n\n const error = configRootType.protoType.verify(config);\n if (error) {\n throw new InvalidConfigError(error);\n }\n\n return config;\n};\n\nexport const ConfigResource = Symbol.for('dxos.resource.Config');\n\n/**\n * Global configuration object.\n * NOTE: Config objects are immutable.\n */\n@trace.resource({ annotation: ConfigResource })\nexport class Config {\n private readonly _config: any;\n\n /**\n * Creates an immutable instance.\n * @constructor\n */\n constructor(config: ConfigProto = {}, ...objects: ConfigProto[]) {\n this._config = validateConfig(defaultsDeep(config, ...objects, { version: 1 }));\n }\n\n /**\n * Returns an immutable config JSON object.\n */\n get values(): ConfigProto {\n return this._config;\n }\n\n /**\n * Returns the given config property.\n *\n * @param key A key in the config object. Can be a nested property with keys separated by dots: 'services.signal.server'.\n * @param defaultValue Default value to return if option is not present in the config.\n * @returns The config value or undefined if the option is not present.\n */\n get<K extends ConfigKey>(\n key: K,\n defaultValue?: DeepIndex<ConfigProto, ParseKey<K>>,\n ): DeepIndex<ConfigProto, ParseKey<K>> | undefined {\n return getDeep(this._config, key.split('.')) ?? defaultValue;\n }\n\n /**\n * Get unique key.\n */\n find<T = any>(path: string, test: object): T | undefined {\n const values = getDeep(this._config, path.split('.'));\n if (!Array.isArray(values)) {\n return;\n }\n\n return values.find((value) => isMatch(value, test));\n }\n\n /**\n * Returns the given config property or throw if it doesn't exist.\n *\n * @param key A key in the config object. Can be a nested property with keys separated by dots: 'services.signal.server'.\n */\n getOrThrow<K extends ConfigKey>(key: K): Exclude<DeepIndex<ConfigProto, ParseKey<K>>, undefined> {\n const value: DeepIndex<ConfigProto, ParseKey<K>> | undefined = getDeep(this._config, key.split('.'));\n if (!value) {\n throw new Error(`Config option not present: ${key}`);\n }\n return value;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,gBAAgB;AACzB,SAASC,oBAAoB;AAC7B,SAASC,eAAe;AAExB,OAAOC,UAAU;AACjB,OAAOC,WAAW;AAElB,SAASC,iBAAiB;AAC1B,SAASC,WAAW;AACpB,SAASC,WAAAA,gBAAe;;;ACTxB,SAASC,eAAe;AACxB,OAAOC,kBAAkB;AACzB,OAAOC,aAAa;AAEpB,SAASC,0BAA0B;AACnC,SAASC,cAAc;AAEvB,SAASC,aAAa;AACtB,SAASC,SAASC,eAAe;;;;;;;;;;;;;;;;;;;;AAKjC,IAAMC,iBAAiBC,OAAOC,gBAAgB,oBAAA;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;IAClBC,kBAAkB,CAAC;IACnBqC,iBAAiB;MAAEC,SAAS/C,SAAS;MAAcG;IAAU;EAC/D,CAAA;AAEJ;",
|
|
6
|
+
"names": ["execSync", "readFileSync", "resolve", "yaml", "pkgUp", "invariant", "log", "setDeep", "boolean", "defaultsDeep", "isMatch", "InvalidConfigError", "schema", "trace", "getDeep", "setDeep", "configRootType", "schema", "getCodecForType", "mapFromKeyValues", "spec", "values", "config", "key", "path", "type", "Object", "entries", "value", "undefined", "boolean", "Number", "JSON", "parse", "Error", "setDeep", "split", "validateConfig", "config", "InvalidConfigError", "version", "error", "configRootType", "protoType", "verify", "ConfigResource", "Symbol", "for", "Config", "values", "_config", "get", "key", "defaultValue", "getDeep", "split", "find", "path", "test", "Array", "isArray", "value", "isMatch", "getOrThrow", "Error", "objects", "defaultsDeep", "resource", "annotation", "CWD", "process", "cwd", "definitions", "configPath", "envPath", "devPath", "mode", "env", "NODE_ENV", "publicUrl", "KEYS_TO_FILE", "__CONFIG_DEFAULTS__", "length", "resolve", "__CONFIG_ENVS__", "__CONFIG_LOCAL__", "Object", "entries", "reduce", "prev", "key", "value", "invariant", "content", "yaml", "load", "readFileSync", "mapFromKeyValues", "forEach", "startsWith", "includes", "setDeep", "timestamp", "Date", "toISOString", "commitHash", "DX_COMMIT_HASH", "execSync", "encoding", "replace", "packagePath", "pkgUp", "sync", "packageJson", "JSON", "parse", "version", "err", "message", "log", "error", "Error", "__DXOS_CONFIG__", "dynamic"]
|
|
7
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
definitions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KVRVDEOZ.mjs";
|
|
5
5
|
|
|
6
|
-
//
|
|
6
|
+
// src/plugin/esbuild-plugin.ts
|
|
7
7
|
var ConfigPlugin = (options = {}) => {
|
|
8
8
|
return {
|
|
9
9
|
name: "dxos-config",
|
|
10
10
|
setup: ({ initialOptions }) => {
|
|
11
|
+
var _esbuildOptions;
|
|
11
12
|
const esbuildOptions = initialOptions;
|
|
12
|
-
esbuildOptions.define
|
|
13
|
+
(_esbuildOptions = esbuildOptions).define || (_esbuildOptions.define = {});
|
|
13
14
|
Object.entries(definitions({
|
|
14
15
|
...options,
|
|
15
16
|
mode: process.env.NODE_ENV
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugin/esbuild-plugin.ts"],
|
|
4
4
|
"sourcesContent": ["//\n// Copyright 2021 DXOS.org\n//\n\nimport type { Plugin } from 'esbuild';\n\nimport { definitions } from './definitions';\nimport { type ConfigPluginOpts } from './types';\n\nexport const ConfigPlugin = (options: ConfigPluginOpts = {}): Plugin => {\n return {\n name: 'dxos-config',\n setup: ({ initialOptions }) => {\n const esbuildOptions = initialOptions;\n esbuildOptions.define ||= {};\n\n Object.entries(definitions({ ...options, mode: process.env.NODE_ENV })).reduce((define, [key, value]) => {\n define[key] = JSON.stringify(value);\n return define;\n }, esbuildOptions.define);\n },\n };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AASO,IAAMA,eAAe,CAACC,UAA4B,CAAC,MAAC;AACzD,SAAO;IACLC,MAAM;IACNC,OAAO,CAAC,EAAEC,eAAc,MAAE;
|
|
5
|
+
"mappings": ";;;;;;AASO,IAAMA,eAAe,CAACC,UAA4B,CAAC,MAAC;AACzD,SAAO;IACLC,MAAM;IACNC,OAAO,CAAC,EAAEC,eAAc,MAAE;UAExBC;AADA,YAAMA,iBAAiBD;AACvBC,OAAAA,kBAAAA,gBAAeC,WAAfD,gBAAeC,SAAW,CAAC;AAE3BC,aAAOC,QAAQC,YAAY;QAAE,GAAGR;QAASS,MAAMC,QAAQC,IAAIC;MAAS,CAAA,CAAA,EAAIC,OAAO,CAACR,QAAQ,CAACS,KAAKC,KAAAA,MAAM;AAClGV,eAAOS,GAAAA,IAAOE,KAAKC,UAAUF,KAAAA;AAC7B,eAAOV;MACT,GAAGD,eAAeC,MAAM;IAC1B;EACF;AACF;",
|
|
6
6
|
"names": ["ConfigPlugin", "options", "name", "setup", "initialOptions", "esbuildOptions", "define", "Object", "entries", "definitions", "mode", "process", "env", "NODE_ENV", "reduce", "key", "value", "JSON", "stringify"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"
|
|
1
|
+
{"inputs":{"src/config.ts":{"bytes":16107,"imports":[{"path":"boolean","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"lodash.ismatch","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/tracing","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/plugin/definitions.ts":{"bytes":12065,"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"js-yaml","kind":"import-statement","external":true},{"path":"pkg-up","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"../config"}],"format":"esm"},"src/plugin/esbuild-plugin.ts":{"bytes":2690,"imports":[{"path":"src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"},"src/plugin/rollup-plugin.ts":{"bytes":2055,"imports":[{"path":"src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"},"src/plugin/vite-plugin.ts":{"bytes":3666,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"}},"outputs":{"dist/plugin/node-esm/esbuild-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1379},"dist/plugin/node-esm/esbuild-plugin.mjs":{"imports":[{"path":"dist/plugin/node-esm/chunk-KVRVDEOZ.mjs","kind":"import-statement"}],"exports":["ConfigPlugin"],"entryPoint":"src/plugin/esbuild-plugin.ts","inputs":{"src/plugin/esbuild-plugin.ts":{"bytesInOutput":516}},"bytes":766},"dist/plugin/node-esm/rollup-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1103},"dist/plugin/node-esm/rollup-plugin.mjs":{"imports":[{"path":"dist/plugin/node-esm/chunk-KVRVDEOZ.mjs","kind":"import-statement"}],"exports":["ConfigPlugin"],"entryPoint":"src/plugin/rollup-plugin.ts","inputs":{"src/plugin/rollup-plugin.ts":{"bytesInOutput":288}},"bytes":536},"dist/plugin/node-esm/vite-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1838},"dist/plugin/node-esm/vite-plugin.mjs":{"imports":[{"path":"dist/plugin/node-esm/chunk-KVRVDEOZ.mjs","kind":"import-statement"},{"path":"node:path","kind":"import-statement","external":true}],"exports":["ConfigPlugin"],"entryPoint":"src/plugin/vite-plugin.ts","inputs":{"src/plugin/vite-plugin.ts":{"bytesInOutput":674}},"bytes":918},"dist/plugin/node-esm/chunk-KVRVDEOZ.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":13173},"dist/plugin/node-esm/chunk-KVRVDEOZ.mjs":{"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"js-yaml","kind":"import-statement","external":true},{"path":"pkg-up","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"boolean","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"lodash.ismatch","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/tracing","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["definitions"],"inputs":{"src/plugin/definitions.ts":{"bytesInOutput":3211},"src/config.ts":{"bytesInOutput":3871}},"bytes":7323}}}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
definitions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KVRVDEOZ.mjs";
|
|
5
5
|
|
|
6
|
-
//
|
|
6
|
+
// src/plugin/rollup-plugin.ts
|
|
7
7
|
var ConfigPlugin = (options = {}) => {
|
|
8
8
|
const contents = Object.entries(definitions({
|
|
9
9
|
...options,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
definitions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KVRVDEOZ.mjs";
|
|
5
5
|
|
|
6
|
-
//
|
|
6
|
+
// src/plugin/vite-plugin.ts
|
|
7
7
|
import { resolve } from "node:path";
|
|
8
8
|
var ConfigPlugin = (options = {}) => ({
|
|
9
9
|
name: "dxos-config",
|
|
10
|
-
config: (
|
|
11
|
-
const configPath = root && resolve(root, options.configPath ?? "dx.yml");
|
|
12
|
-
const envPath = root && resolve(root, options.envPath ?? "dx-env.yml");
|
|
13
|
-
const devPath = root && resolve(root, options.devPath ?? "dx-local.yml");
|
|
10
|
+
config: () => {
|
|
11
|
+
const configPath = options.root && resolve(options.root, options.configPath ?? "dx.yml");
|
|
12
|
+
const envPath = options.root && resolve(options.root, options.envPath ?? "dx-env.yml");
|
|
13
|
+
const devPath = options.root && resolve(options.root, options.devPath ?? "dx-local.yml");
|
|
14
14
|
const define = Object.entries(definitions({
|
|
15
15
|
...options,
|
|
16
16
|
configPath,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugin/vite-plugin.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { resolve } from 'node:path';\nimport type
|
|
5
|
-
"mappings": ";;;;;;AAIA,SAASA,eAAe;
|
|
6
|
-
"names": ["resolve", "ConfigPlugin", "options", "name", "config", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { resolve } from 'node:path';\n\nimport { type Plugin } from 'vite';\n\nimport { definitions } from './definitions';\nimport { type ConfigPluginOpts } from './types';\n\nexport const ConfigPlugin = (options: ConfigPluginOpts = {}): Plugin => ({\n name: 'dxos-config',\n config: () => {\n // Update paths.\n const configPath = options.root && resolve(options.root, options.configPath ?? 'dx.yml');\n const envPath = options.root && resolve(options.root, options.envPath ?? 'dx-env.yml');\n // TODO(burdon): Change to dx-dev.yml?\n const devPath = options.root && resolve(options.root, options.devPath ?? 'dx-local.yml');\n\n const define = Object.entries(definitions({ ...options, configPath, envPath, devPath })).reduce(\n (define, [key, value]) => {\n define[key] = JSON.stringify(value);\n return define;\n },\n {} as { [key: string]: string },\n );\n\n return { define };\n },\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,SAASA,eAAe;AAOjB,IAAMC,eAAe,CAACC,UAA4B,CAAC,OAAe;EACvEC,MAAM;EACNC,QAAQ,MAAA;AAEN,UAAMC,aAAaH,QAAQI,QAAQC,QAAQL,QAAQI,MAAMJ,QAAQG,cAAc,QAAA;AAC/E,UAAMG,UAAUN,QAAQI,QAAQC,QAAQL,QAAQI,MAAMJ,QAAQM,WAAW,YAAA;AAEzE,UAAMC,UAAUP,QAAQI,QAAQC,QAAQL,QAAQI,MAAMJ,QAAQO,WAAW,cAAA;AAEzE,UAAMC,SAASC,OAAOC,QAAQC,YAAY;MAAE,GAAGX;MAASG;MAAYG;MAASC;IAAQ,CAAA,CAAA,EAAIK,OACvF,CAACJ,SAAQ,CAACK,KAAKC,KAAAA,MAAM;AACnBN,MAAAA,QAAOK,GAAAA,IAAOE,KAAKC,UAAUF,KAAAA;AAC7B,aAAON;IACT,GACA,CAAC,CAAA;AAGH,WAAO;MAAEA;IAAO;EAClB;AACF;",
|
|
6
|
+
"names": ["resolve", "ConfigPlugin", "options", "name", "config", "configPath", "root", "resolve", "envPath", "devPath", "define", "Object", "entries", "definitions", "reduce", "key", "value", "JSON", "stringify"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/loaders/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/loaders/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,MAAM,IAAI,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAqB/E;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,gBAAmB,KAEL,WACrC,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,KAAK,QAAO,OAAO,CAAC,WAAW,CAAS,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAO,OAAO,CAAC,WAAW,CAAS,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,IAAI,GAAI,iBAA4B,KAAG,OAAO,CAAC,WAAW,CAGtE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,iBAA4B,KAAG,OAAO,CAAC,WAAW,CACf,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,OAAO,QAAa,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAS,CAAC;AAEvE,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,GAAG,SAAS,EAAE,sBAAsB,MAAM,KAAG,OAAO,CAAC,WAAW,CAqBpG,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type ConfigPluginOpts } from './types';
|
|
2
2
|
export declare const definitions: ({ configPath, envPath, devPath, mode, publicUrl, env, }: ConfigPluginOpts) => {
|
|
3
|
+
__CONFIG_DEFAULTS__: {};
|
|
4
|
+
__CONFIG_ENVS__: {};
|
|
5
|
+
__CONFIG_LOCAL__: {};
|
|
3
6
|
__DXOS_CONFIG__: {
|
|
4
7
|
dynamic: boolean;
|
|
5
8
|
publicUrl: string;
|
|
6
9
|
};
|
|
7
|
-
__CONFIG_DEFAULTS__: {};
|
|
8
|
-
__CONFIG_ENVS__: {};
|
|
9
|
-
__CONFIG_LOCAL__: {};
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../../src/plugin/definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../../src/plugin/definitions.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD,eAAO,MAAM,WAAW,GAAI,yDAOzB,gBAAgB;;;;;;;;CAmElB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugin/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugin/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,mBAAmB,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugin/types.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugin/types.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugin/vite-plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugin/vite-plugin.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,YAAY,GAAI,UAAS,gBAAqB,KAAG,MAmB5D,CAAC"}
|