@likec4/config 1.39.5 → 1.41.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/dist/index.d.mts +1589 -0
- package/dist/index.mjs +1 -11
- package/dist/node/index.d.mts +13 -0
- package/dist/node/index.mjs +59 -2
- package/dist/shared/config.BgYO9fOn.mjs +3251 -0
- package/package.json +11 -11
- package/src/schema.image-alias.ts +1 -1
- package/src/schema.ts +2 -3
- package/dist/define-config.d.ts +0 -45
- package/dist/define-config.mjs +0 -7
- package/dist/filenames.d.ts +0 -16
- package/dist/filenames.mjs +0 -34
- package/dist/index.d.ts +0 -4
- package/dist/logger.d.ts +0 -1
- package/dist/logger.mjs +0 -2
- package/dist/node/index.d.ts +0 -2
- package/dist/node/load-config.d.ts +0 -7
- package/dist/node/load-config.mjs +0 -55
- package/dist/schema.d.ts +0 -149
- package/dist/schema.image-alias.d.ts +0 -5
- package/dist/schema.image-alias.mjs +0 -42
- package/dist/schema.mjs +0 -38
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
export { serializableLikeC4ProjectConfig, validateProjectConfig } from
|
|
2
|
-
export {
|
|
3
|
-
ConfigFilenames,
|
|
4
|
-
isLikeC4Config,
|
|
5
|
-
isLikeC4JsonConfig,
|
|
6
|
-
isLikeC4NonJsonConfig
|
|
7
|
-
} from "./filenames.mjs";
|
|
8
|
-
export {
|
|
9
|
-
defineConfig,
|
|
10
|
-
defineGenerators
|
|
11
|
-
} from "./define-config.mjs";
|
|
1
|
+
export { C as ConfigFilenames, d as defineConfig, c as defineGenerators, i as isLikeC4Config, a as isLikeC4JsonConfig, b as isLikeC4NonJsonConfig, s as serializableLikeC4ProjectConfig, v as validateProjectConfig } from './shared/config.BgYO9fOn.mjs';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { URI } from 'vscode-uri';
|
|
2
|
+
import { LikeC4ProjectConfig } from '../index.mjs';
|
|
3
|
+
export { ConfigFilenames, GeneratorFn, GeneratorFnContext, GeneratorFnParams, LikeC4ProjectJsonConfig, defineConfig, defineGenerators, isLikeC4Config, isLikeC4JsonConfig, isLikeC4NonJsonConfig, serializableLikeC4ProjectConfig, validateProjectConfig } from '../index.mjs';
|
|
4
|
+
import '@likec4/core/model';
|
|
5
|
+
import '@likec4/core/types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Load LikeC4 Project config file.
|
|
9
|
+
* If filepath is a non-JSON file, it will be bundled and required
|
|
10
|
+
*/
|
|
11
|
+
declare function loadConfig(filepath: URI): Promise<LikeC4ProjectConfig>;
|
|
12
|
+
|
|
13
|
+
export { LikeC4ProjectConfig, loadConfig };
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,2 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { invariant } from '@likec4/core';
|
|
2
|
+
import { bundleRequire } from 'bundle-require';
|
|
3
|
+
import * as fs from 'node:fs/promises';
|
|
4
|
+
import { dirname } from 'node:path';
|
|
5
|
+
import { a as isLikeC4JsonConfig, v as validateProjectConfig, b as isLikeC4NonJsonConfig, d as defineConfig } from '../shared/config.BgYO9fOn.mjs';
|
|
6
|
+
export { C as ConfigFilenames, c as defineGenerators, i as isLikeC4Config, s as serializableLikeC4ProjectConfig } from '../shared/config.BgYO9fOn.mjs';
|
|
7
|
+
import { rootLogger } from '@likec4/log';
|
|
8
|
+
|
|
9
|
+
const logger = rootLogger.getChild("config");
|
|
10
|
+
|
|
11
|
+
async function loadConfig(filepath) {
|
|
12
|
+
logger.debug`Loading config file: ${filepath.fsPath}`;
|
|
13
|
+
if (isLikeC4JsonConfig(filepath.fsPath)) {
|
|
14
|
+
try {
|
|
15
|
+
const content = await fs.readFile(filepath.fsPath, "utf-8");
|
|
16
|
+
return validateProjectConfig(content);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
logger.error(`Failed to load json config file: ${filepath.fsPath}`, { err });
|
|
19
|
+
throw err;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
invariant(isLikeC4NonJsonConfig(filepath.fsPath), `Invalid config file: ${filepath.fsPath}`);
|
|
23
|
+
try {
|
|
24
|
+
const cwd = dirname(filepath.fsPath);
|
|
25
|
+
const { mod } = await bundleRequire({
|
|
26
|
+
filepath: filepath.fsPath,
|
|
27
|
+
cwd,
|
|
28
|
+
esbuildOptions: {
|
|
29
|
+
resolveExtensions: [".mjs", ".js", ".ts", ".mts"],
|
|
30
|
+
plugins: [{
|
|
31
|
+
name: "likec4-config",
|
|
32
|
+
setup(build) {
|
|
33
|
+
build.onResolve({ filter: /^@?likec4\/config$/ }, (args) => ({
|
|
34
|
+
path: args.path,
|
|
35
|
+
namespace: "likec4-config"
|
|
36
|
+
}));
|
|
37
|
+
build.onLoad({ filter: /.*/, namespace: "likec4-config" }, (args) => {
|
|
38
|
+
return {
|
|
39
|
+
contents: `
|
|
40
|
+
function mockDefineConfig(x) { return x }
|
|
41
|
+
export {
|
|
42
|
+
mockDefineConfig as defineConfig,
|
|
43
|
+
mockDefineConfig as defineGenerators,
|
|
44
|
+
}`,
|
|
45
|
+
loader: "js"
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}]
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return defineConfig(mod?.default ?? mod);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
logger.error(`Failed to load config file: ${filepath.fsPath}`, { err });
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { defineConfig, isLikeC4JsonConfig, isLikeC4NonJsonConfig, loadConfig, validateProjectConfig };
|