@powerlines/plugin-env 0.15.60 → 0.15.62
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/README.md +305 -0
- package/dist/babel/plugin.cjs +6 -6
- package/dist/babel/plugin.mjs +6 -6
- package/dist/components/docs.cjs +4 -4
- package/dist/components/docs.mjs +4 -4
- package/dist/components/env.cjs +2 -2
- package/dist/components/env.mjs +2 -2
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/helpers/automd-generator.cjs +2 -2
- package/dist/helpers/automd-generator.mjs +2 -2
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers/index.mjs +1 -1
- package/dist/helpers/load.cjs +4 -4
- package/dist/helpers/load.mjs +4 -4
- package/dist/helpers/persistence.cjs +6 -6
- package/dist/helpers/persistence.mjs +6 -6
- package/dist/helpers/reflect.cjs +4 -4
- package/dist/helpers/reflect.mjs +4 -4
- package/dist/index.cjs +25 -25
- package/dist/index.mjs +25 -25
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/parse-type-definition.cjs +37 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/parse-type-definition.mjs +37 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/to-array.cjs +15 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/to-array.mjs +14 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/get-object-tag.cjs +15 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/get-object-tag.mjs +14 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-buffer.cjs +6 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-buffer.mjs +6 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-object.cjs +19 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-object.mjs +19 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-plain-object.cjs +63 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-plain-object.mjs +63 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-string.cjs +12 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-string.mjs +11 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/type-detect.cjs +15 -0
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/type-detect.mjs +16 -0
- package/dist/node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/is-parent-path.cjs +32 -0
- package/dist/node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/is-parent-path.mjs +32 -0
- package/dist/node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/is-type.cjs +28 -0
- package/dist/node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/is-type.mjs +28 -0
- package/dist/node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/join-paths.cjs +106 -0
- package/dist/node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/join-paths.mjs +106 -0
- package/dist/node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/regex.cjs +12 -0
- package/dist/node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/regex.mjs +8 -0
- package/dist/node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/slash.cjs +15 -0
- package/dist/node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/slash.mjs +14 -0
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.1/node_modules/c12/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.1/node_modules/c12/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.cjs +1 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +1 -1
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs +1 -1
- package/dist/packages/powerlines/src/types/config.d.mts +1 -1
- package/package.json +16 -16
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/parse-type-definition.cjs +0 -31
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/parse-type-definition.mjs +0 -31
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/to-array.cjs +0 -8
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/to-array.mjs +0 -7
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/get-object-tag.cjs +0 -6
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/get-object-tag.mjs +0 -5
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/is-buffer.cjs +0 -6
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/is-buffer.mjs +0 -6
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/is-object.cjs +0 -13
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/is-object.mjs +0 -13
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/is-plain-object.cjs +0 -13
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/is-plain-object.mjs +0 -13
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/is-string.cjs +0 -12
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/is-string.mjs +0 -11
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/type-detect.cjs +0 -11
- package/dist/node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/type-checks/src/type-detect.mjs +0 -12
- package/dist/node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/is-parent-path.cjs +0 -10
- package/dist/node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/is-parent-path.mjs +0 -10
- package/dist/node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/is-type.cjs +0 -13
- package/dist/node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/is-type.mjs +0 -13
- package/dist/node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/join-paths.cjs +0 -49
- package/dist/node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/join-paths.mjs +0 -49
- package/dist/node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/regex.cjs +0 -9
- package/dist/node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/regex.mjs +0 -5
- package/dist/node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/slash.cjs +0 -8
- package/dist/node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/slash.mjs +0 -7
- /package/dist/node_modules/.pnpm/{@stryke_convert@0.6.32 → @stryke_convert@0.6.34}/node_modules/@stryke/convert/dist/type-checks/src/index.cjs +0 -0
- /package/dist/node_modules/.pnpm/{@stryke_convert@0.6.32 → @stryke_convert@0.6.34}/node_modules/@stryke/convert/dist/type-checks/src/index.mjs +0 -0
- /package/dist/node_modules/.pnpm/{@stryke_convert@0.6.32 → @stryke_convert@0.6.34}/node_modules/@stryke/convert/dist/type-checks/src/is-collection.cjs +0 -0
- /package/dist/node_modules/.pnpm/{@stryke_convert@0.6.32 → @stryke_convert@0.6.34}/node_modules/@stryke/convert/dist/type-checks/src/is-collection.mjs +0 -0
package/dist/helpers/reflect.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_is_parent_path = require('../node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/is-parent-path.cjs');
|
|
3
|
-
const require_join_paths = require('../node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/join-paths.cjs');
|
|
4
2
|
const require_types_runtime = require('../types/runtime.cjs');
|
|
5
3
|
const require_types_plugin = require('../types/plugin.cjs');
|
|
4
|
+
const require_join_paths = require('../node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/join-paths.cjs');
|
|
5
|
+
const require_is_parent_path = require('../node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/is-parent-path.cjs');
|
|
6
6
|
const require_helpers_persistence = require('./persistence.cjs');
|
|
7
7
|
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
8
8
|
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
@@ -211,7 +211,7 @@ createSecretsReflection.__type = [
|
|
|
211
211
|
async function reflectEnv(context, file, name) {
|
|
212
212
|
let config;
|
|
213
213
|
if (file) config = (0, __powerlines_deepkit_vendor_type.resolveClassType)(await (0, __powerlines_deepkit_reflect_type.reflectType)(context, {
|
|
214
|
-
file: !require_is_parent_path.
|
|
214
|
+
file: !require_is_parent_path.isParentPath(file, context.workspaceConfig.workspaceRoot) ? require_join_paths.joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
|
|
215
215
|
name
|
|
216
216
|
}));
|
|
217
217
|
const defaultConfigType = await (0, __powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getEnvDefaultTypeDefinition(context));
|
|
@@ -232,7 +232,7 @@ reflectEnv.__type = [
|
|
|
232
232
|
async function reflectSecrets(context, file, name) {
|
|
233
233
|
let config;
|
|
234
234
|
if (file) config = (0, __powerlines_deepkit_vendor_type.resolveClassType)(await (0, __powerlines_deepkit_reflect_type.reflectType)(context, {
|
|
235
|
-
file: !require_is_parent_path.
|
|
235
|
+
file: !require_is_parent_path.isParentPath(file, context.workspaceConfig.workspaceRoot) ? require_join_paths.joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
|
|
236
236
|
name
|
|
237
237
|
}));
|
|
238
238
|
const defaultSecretsType = await (0, __powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getSecretsDefaultTypeDefinition(context));
|
package/dist/helpers/reflect.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t } from "../node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/is-parent-path.mjs";
|
|
2
|
-
import { o } from "../node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/join-paths.mjs";
|
|
3
1
|
import { __ΩEnvInterface, __ΩSecretsInterface } from "../types/runtime.mjs";
|
|
4
2
|
import { __ΩEnvPluginContext } from "../types/plugin.mjs";
|
|
3
|
+
import { joinPaths } from "../node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/join-paths.mjs";
|
|
4
|
+
import { isParentPath } from "../node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/is-parent-path.mjs";
|
|
5
5
|
import { getEnvDefaultTypeDefinition, getSecretsDefaultTypeDefinition, readEnvTypeReflection, readSecretsReflection } from "./persistence.mjs";
|
|
6
6
|
import { ReflectionClass, ReflectionKind, __ΩTypeClass, __ΩTypeObjectLiteral, merge, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
7
7
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
@@ -210,7 +210,7 @@ createSecretsReflection.__type = [
|
|
|
210
210
|
async function reflectEnv(context, file, name) {
|
|
211
211
|
let config;
|
|
212
212
|
if (file) config = resolveClassType(await reflectType(context, {
|
|
213
|
-
file: !
|
|
213
|
+
file: !isParentPath(file, context.workspaceConfig.workspaceRoot) ? joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
|
|
214
214
|
name
|
|
215
215
|
}));
|
|
216
216
|
const defaultConfigType = await reflectType(context, await getEnvDefaultTypeDefinition(context));
|
|
@@ -231,7 +231,7 @@ reflectEnv.__type = [
|
|
|
231
231
|
async function reflectSecrets(context, file, name) {
|
|
232
232
|
let config;
|
|
233
233
|
if (file) config = resolveClassType(await reflectType(context, {
|
|
234
|
-
file: !
|
|
234
|
+
file: !isParentPath(file, context.workspaceConfig.workspaceRoot) ? joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
|
|
235
235
|
name
|
|
236
236
|
}));
|
|
237
237
|
const defaultSecretsType = await reflectType(context, await getSecretsDefaultTypeDefinition(context));
|
package/dist/index.cjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
-
const require_parse_type_definition = require('./node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/parse-type-definition.cjs');
|
|
4
|
-
const require_to_array = require('./node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/to-array.cjs');
|
|
5
|
-
const require_is_parent_path = require('./node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/is-parent-path.cjs');
|
|
6
|
-
const require_join_paths = require('./node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/join-paths.cjs');
|
|
7
|
-
const require_defu = require('./node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.cjs');
|
|
8
3
|
const require_types_runtime = require('./types/runtime.cjs');
|
|
9
4
|
const require_types_plugin = require('./types/plugin.cjs');
|
|
5
|
+
require('./types/index.cjs');
|
|
6
|
+
const require_join_paths = require('./node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/join-paths.cjs');
|
|
7
|
+
const require_is_parent_path = require('./node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/is-parent-path.cjs');
|
|
10
8
|
const require_helpers_reflect = require('./helpers/reflect.cjs');
|
|
11
9
|
const require_helpers_persistence = require('./helpers/persistence.cjs');
|
|
12
|
-
const
|
|
10
|
+
const require_helpers_template_helpers = require('./helpers/template-helpers.cjs');
|
|
13
11
|
const require_helpers_source_file_env = require('./helpers/source-file-env.cjs');
|
|
12
|
+
const require_defu = require('./node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.cjs');
|
|
14
13
|
const require_helpers_load = require('./helpers/load.cjs');
|
|
15
14
|
const require_helpers_create_reflection_resource = require('./helpers/create-reflection-resource.cjs');
|
|
16
|
-
|
|
15
|
+
require('./helpers/index.cjs');
|
|
17
16
|
const require_helpers_automd_generator = require('./helpers/automd-generator.cjs');
|
|
18
|
-
require('./babel/index.cjs');
|
|
19
17
|
const require_components_docs = require('./components/docs.cjs');
|
|
18
|
+
const require_components_env = require('./components/env.cjs');
|
|
20
19
|
require('./components/index.cjs');
|
|
21
|
-
const
|
|
22
|
-
require('./
|
|
23
|
-
require('./
|
|
24
|
-
|
|
20
|
+
const require_babel_plugin = require('./babel/plugin.cjs');
|
|
21
|
+
require('./babel/index.cjs');
|
|
22
|
+
const require_parse_type_definition = require('./node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/parse-type-definition.cjs');
|
|
23
|
+
const require_to_array = require('./node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/to-array.cjs');
|
|
25
24
|
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
25
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
26
|
+
let __stryke_env_types = require("@stryke/env/types");
|
|
27
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
28
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
26
29
|
let __powerlines_plugin_alloy = require("@powerlines/plugin-alloy");
|
|
27
30
|
__powerlines_plugin_alloy = require_rolldown_runtime.__toESM(__powerlines_plugin_alloy);
|
|
28
31
|
let __powerlines_plugin_automd = require("@powerlines/plugin-automd");
|
|
29
32
|
__powerlines_plugin_automd = require_rolldown_runtime.__toESM(__powerlines_plugin_automd);
|
|
30
33
|
let __powerlines_plugin_babel = require("@powerlines/plugin-babel");
|
|
31
34
|
__powerlines_plugin_babel = require_rolldown_runtime.__toESM(__powerlines_plugin_babel);
|
|
32
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
33
|
-
let __stryke_env_types = require("@stryke/env/types");
|
|
34
35
|
let __stryke_fs_exists = require("@stryke/fs/exists");
|
|
35
36
|
let __stryke_fs_helpers = require("@stryke/fs/helpers");
|
|
36
37
|
let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
37
|
-
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
38
38
|
|
|
39
39
|
//#region src/index.tsx
|
|
40
40
|
/**
|
|
@@ -55,18 +55,18 @@ const plugin = (options = {}) => {
|
|
|
55
55
|
}),
|
|
56
56
|
transform: { babel: { plugins: [require_babel_plugin.envBabelPlugin] } }
|
|
57
57
|
};
|
|
58
|
-
if (config.env.types) config.env.types = require_parse_type_definition.
|
|
58
|
+
if (config.env.types) config.env.types = require_parse_type_definition.parseTypeDefinition(config.env.types);
|
|
59
59
|
else {
|
|
60
60
|
this.log(__storm_software_config_tools_types.LogLevelLabel.WARN, "The `env.types` configuration parameter was not provided. Please ensure this is expected.");
|
|
61
61
|
const envDefaultTypeDefinition = await require_helpers_persistence.getEnvDefaultTypeDefinition(this);
|
|
62
|
-
config.env.types = require_parse_type_definition.
|
|
62
|
+
config.env.types = require_parse_type_definition.parseTypeDefinition(`${envDefaultTypeDefinition.file}#${envDefaultTypeDefinition.name}`);
|
|
63
63
|
}
|
|
64
|
-
if (config.env.secrets) config.env.secrets = require_parse_type_definition.
|
|
64
|
+
if (config.env.secrets) config.env.secrets = require_parse_type_definition.parseTypeDefinition(config.env.secrets);
|
|
65
65
|
else {
|
|
66
66
|
const secretsDefaultTypeDefinition = await require_helpers_persistence.getSecretsDefaultTypeDefinition(this);
|
|
67
|
-
config.env.secrets = require_parse_type_definition.
|
|
67
|
+
config.env.secrets = require_parse_type_definition.parseTypeDefinition(`${secretsDefaultTypeDefinition.file}#${secretsDefaultTypeDefinition.name}`);
|
|
68
68
|
}
|
|
69
|
-
config.env.prefix = require_to_array.
|
|
69
|
+
config.env.prefix = require_to_array.toArray(config.env.prefix ?? []).reduce((ret, prefix) => {
|
|
70
70
|
const formattedPrefix = (0, __stryke_string_format_constant_case.constantCase)(prefix);
|
|
71
71
|
if (!ret.includes(formattedPrefix)) ret.push(formattedPrefix);
|
|
72
72
|
return ret;
|
|
@@ -75,7 +75,7 @@ const plugin = (options = {}) => {
|
|
|
75
75
|
"POWERLINES_",
|
|
76
76
|
this.config.framework && this.config.framework !== "powerlines" && `${(0, __stryke_string_format_constant_case.constantCase)(this.config.framework)}_`
|
|
77
77
|
].filter(Boolean));
|
|
78
|
-
config.env.prefix = require_to_array.
|
|
78
|
+
config.env.prefix = require_to_array.toArray(config.env.prefix).reduce((ret, prefix) => {
|
|
79
79
|
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
80
80
|
return ret;
|
|
81
81
|
}, []);
|
|
@@ -100,10 +100,10 @@ const plugin = (options = {}) => {
|
|
|
100
100
|
if ((0, __stryke_fs_exists.existsSync)(require_helpers_persistence.getEnvTypeReflectionsPath(this, "secrets"))) this.env.types.secrets = await require_helpers_persistence.readEnvTypeReflection(this, "secrets");
|
|
101
101
|
if ((0, __stryke_fs_exists.existsSync)(require_helpers_persistence.getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await require_helpers_persistence.readSecretsReflection(this);
|
|
102
102
|
} else {
|
|
103
|
-
this.env.types.env = await require_helpers_reflect.reflectEnv(this, this.config.env.types?.file ? require_is_parent_path.
|
|
103
|
+
this.env.types.env = await require_helpers_reflect.reflectEnv(this, this.config.env.types?.file ? require_is_parent_path.isParentPath(this.config.env.types?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.types?.file : require_join_paths.joinPaths(this.config.projectRoot, this.config.env.types?.file) : void 0, this.config.env.types?.name);
|
|
104
104
|
if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
|
|
105
105
|
await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.env, "env");
|
|
106
|
-
this.env.types.secrets = await require_helpers_reflect.reflectSecrets(this, this.config.env.secrets?.file ? require_is_parent_path.
|
|
106
|
+
this.env.types.secrets = await require_helpers_reflect.reflectSecrets(this, this.config.env.secrets?.file ? require_is_parent_path.isParentPath(this.config.env.secrets?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.secrets?.file : require_join_paths.joinPaths(this.config.projectRoot, this.config.env.secrets?.file) : void 0, this.config.env.secrets?.name);
|
|
107
107
|
if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
|
|
108
108
|
await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
109
109
|
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
|
|
@@ -144,10 +144,10 @@ const plugin = (options = {}) => {
|
|
|
144
144
|
},
|
|
145
145
|
async docs() {
|
|
146
146
|
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Writing Environment documentation for the Powerlines project artifacts.");
|
|
147
|
-
const outputPath = require_join_paths.
|
|
147
|
+
const outputPath = require_join_paths.joinPaths(this.config.projectRoot, "docs", "generated");
|
|
148
148
|
if (!(0, __stryke_fs_exists.existsSync)(outputPath)) await (0, __stryke_fs_helpers.createDirectory)(outputPath);
|
|
149
149
|
const reflection = await require_helpers_persistence.readEnvTypeReflection(this, "env");
|
|
150
|
-
const envDocFile = require_join_paths.
|
|
150
|
+
const envDocFile = require_join_paths.joinPaths(outputPath, "env.md");
|
|
151
151
|
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Documenting environment variables configuration in "${envDocFile}"`);
|
|
152
152
|
await this.fs.write(envDocFile, `<!-- Generated by ${(0, __stryke_string_format_title_case.titleCase)(this.config.framework) || "Powerlines"} -->
|
|
153
153
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { n } from "./node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/parse-type-definition.mjs";
|
|
2
|
-
import { e } from "./node_modules/.pnpm/@stryke_convert@0.6.32/node_modules/@stryke/convert/dist/to-array.mjs";
|
|
3
|
-
import { t } from "./node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/is-parent-path.mjs";
|
|
4
|
-
import { o } from "./node_modules/.pnpm/@stryke_path@0.24.3/node_modules/@stryke/path/dist/join-paths.mjs";
|
|
5
|
-
import { defu } from "./node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs";
|
|
6
1
|
import { __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.mjs";
|
|
7
2
|
import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.mjs";
|
|
3
|
+
import "./types/index.mjs";
|
|
4
|
+
import { joinPaths } from "./node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/join-paths.mjs";
|
|
5
|
+
import { isParentPath } from "./node_modules/.pnpm/@stryke_path@0.25.3/node_modules/@stryke/path/dist/is-parent-path.mjs";
|
|
8
6
|
import { BaseEnv, BaseSecrets, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./helpers/reflect.mjs";
|
|
9
7
|
import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from "./helpers/persistence.mjs";
|
|
10
|
-
import {
|
|
8
|
+
import { createTemplateReflection } from "./helpers/template-helpers.mjs";
|
|
11
9
|
import { formatEnvField, removeEnvPrefix } from "./helpers/source-file-env.mjs";
|
|
10
|
+
import { defu } from "./node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs";
|
|
12
11
|
import { loadEnv, loadEnvFromContext } from "./helpers/load.mjs";
|
|
13
12
|
import { createReflectionResource } from "./helpers/create-reflection-resource.mjs";
|
|
14
|
-
import
|
|
13
|
+
import "./helpers/index.mjs";
|
|
15
14
|
import { env } from "./helpers/automd-generator.mjs";
|
|
16
|
-
import "./babel/index.mjs";
|
|
17
15
|
import { EnvDocs } from "./components/docs.mjs";
|
|
16
|
+
import { EnvBuiltin, EnvTypeDefinition } from "./components/env.mjs";
|
|
18
17
|
import "./components/index.mjs";
|
|
19
|
-
import {
|
|
20
|
-
import "./
|
|
21
|
-
import "./
|
|
22
|
-
import {
|
|
18
|
+
import { envBabelPlugin } from "./babel/plugin.mjs";
|
|
19
|
+
import "./babel/index.mjs";
|
|
20
|
+
import { parseTypeDefinition } from "./node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/parse-type-definition.mjs";
|
|
21
|
+
import { toArray } from "./node_modules/.pnpm/@stryke_convert@0.6.34/node_modules/@stryke/convert/dist/to-array.mjs";
|
|
23
22
|
import { ReflectionClass, ReflectionKind, stringifyType } from "@powerlines/deepkit/vendor/type";
|
|
23
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
24
|
+
import { ENV_PREFIXES } from "@stryke/env/types";
|
|
25
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
26
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
24
27
|
import alloy from "@powerlines/plugin-alloy";
|
|
25
28
|
import automd from "@powerlines/plugin-automd";
|
|
26
29
|
import babel from "@powerlines/plugin-babel";
|
|
27
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
28
|
-
import { ENV_PREFIXES } from "@stryke/env/types";
|
|
29
30
|
import { existsSync } from "@stryke/fs/exists";
|
|
30
31
|
import { createDirectory } from "@stryke/fs/helpers";
|
|
31
32
|
import { constantCase } from "@stryke/string-format/constant-case";
|
|
32
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
33
33
|
|
|
34
34
|
//#region src/index.tsx
|
|
35
35
|
/**
|
|
@@ -50,18 +50,18 @@ const plugin = (options = {}) => {
|
|
|
50
50
|
}),
|
|
51
51
|
transform: { babel: { plugins: [envBabelPlugin] } }
|
|
52
52
|
};
|
|
53
|
-
if (config.env.types) config.env.types =
|
|
53
|
+
if (config.env.types) config.env.types = parseTypeDefinition(config.env.types);
|
|
54
54
|
else {
|
|
55
55
|
this.log(LogLevelLabel.WARN, "The `env.types` configuration parameter was not provided. Please ensure this is expected.");
|
|
56
56
|
const envDefaultTypeDefinition = await getEnvDefaultTypeDefinition(this);
|
|
57
|
-
config.env.types =
|
|
57
|
+
config.env.types = parseTypeDefinition(`${envDefaultTypeDefinition.file}#${envDefaultTypeDefinition.name}`);
|
|
58
58
|
}
|
|
59
|
-
if (config.env.secrets) config.env.secrets =
|
|
59
|
+
if (config.env.secrets) config.env.secrets = parseTypeDefinition(config.env.secrets);
|
|
60
60
|
else {
|
|
61
61
|
const secretsDefaultTypeDefinition = await getSecretsDefaultTypeDefinition(this);
|
|
62
|
-
config.env.secrets =
|
|
62
|
+
config.env.secrets = parseTypeDefinition(`${secretsDefaultTypeDefinition.file}#${secretsDefaultTypeDefinition.name}`);
|
|
63
63
|
}
|
|
64
|
-
config.env.prefix =
|
|
64
|
+
config.env.prefix = toArray(config.env.prefix ?? []).reduce((ret, prefix) => {
|
|
65
65
|
const formattedPrefix = constantCase(prefix);
|
|
66
66
|
if (!ret.includes(formattedPrefix)) ret.push(formattedPrefix);
|
|
67
67
|
return ret;
|
|
@@ -70,7 +70,7 @@ const plugin = (options = {}) => {
|
|
|
70
70
|
"POWERLINES_",
|
|
71
71
|
this.config.framework && this.config.framework !== "powerlines" && `${constantCase(this.config.framework)}_`
|
|
72
72
|
].filter(Boolean));
|
|
73
|
-
config.env.prefix =
|
|
73
|
+
config.env.prefix = toArray(config.env.prefix).reduce((ret, prefix) => {
|
|
74
74
|
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
75
75
|
return ret;
|
|
76
76
|
}, []);
|
|
@@ -95,10 +95,10 @@ const plugin = (options = {}) => {
|
|
|
95
95
|
if (existsSync(getEnvTypeReflectionsPath(this, "secrets"))) this.env.types.secrets = await readEnvTypeReflection(this, "secrets");
|
|
96
96
|
if (existsSync(getEnvReflectionsPath(this, "secrets"))) this.env.used.secrets = await readSecretsReflection(this);
|
|
97
97
|
} else {
|
|
98
|
-
this.env.types.env = await reflectEnv(this, this.config.env.types?.file ?
|
|
98
|
+
this.env.types.env = await reflectEnv(this, this.config.env.types?.file ? isParentPath(this.config.env.types?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.types?.file : joinPaths(this.config.projectRoot, this.config.env.types?.file) : void 0, this.config.env.types?.name);
|
|
99
99
|
if (!this.env.types.env) throw new Error("Failed to find the environment configuration type reflection in the context.");
|
|
100
100
|
await writeEnvTypeReflection(this, this.env.types.env, "env");
|
|
101
|
-
this.env.types.secrets = await reflectSecrets(this, this.config.env.secrets?.file ?
|
|
101
|
+
this.env.types.secrets = await reflectSecrets(this, this.config.env.secrets?.file ? isParentPath(this.config.env.secrets?.file, this.workspaceConfig.workspaceRoot) ? this.config.env.secrets?.file : joinPaths(this.config.projectRoot, this.config.env.secrets?.file) : void 0, this.config.env.secrets?.name);
|
|
102
102
|
if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
|
|
103
103
|
await writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
104
104
|
this.log(LogLevelLabel.TRACE, `Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
|
|
@@ -139,10 +139,10 @@ const plugin = (options = {}) => {
|
|
|
139
139
|
},
|
|
140
140
|
async docs() {
|
|
141
141
|
this.log(LogLevelLabel.TRACE, "Writing Environment documentation for the Powerlines project artifacts.");
|
|
142
|
-
const outputPath =
|
|
142
|
+
const outputPath = joinPaths(this.config.projectRoot, "docs", "generated");
|
|
143
143
|
if (!existsSync(outputPath)) await createDirectory(outputPath);
|
|
144
144
|
const reflection = await readEnvTypeReflection(this, "env");
|
|
145
|
-
const envDocFile =
|
|
145
|
+
const envDocFile = joinPaths(outputPath, "env.md");
|
|
146
146
|
this.log(LogLevelLabel.TRACE, `Documenting environment variables configuration in "${envDocFile}"`);
|
|
147
147
|
await this.fs.write(envDocFile, `<!-- Generated by ${titleCase(this.config.framework) || "Powerlines"} -->
|
|
148
148
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const require_is_object = require('./type-checks/src/is-object.cjs');
|
|
2
|
+
const require_is_string = require('./type-checks/src/is-string.cjs');
|
|
3
|
+
require('./type-checks/src/index.cjs');
|
|
4
|
+
|
|
5
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/parse-type-definition.mjs
|
|
6
|
+
/**
|
|
7
|
+
* Parse a type definition parameter into a {@link TypeDefinition} object
|
|
8
|
+
*
|
|
9
|
+
* @param param - The parameter to parse
|
|
10
|
+
* @returns The parsed type definition
|
|
11
|
+
*/
|
|
12
|
+
const parseTypeDefinition = (param) => {
|
|
13
|
+
if (require_is_string.isString(param)) {
|
|
14
|
+
if (param.includes(":")) {
|
|
15
|
+
const params = param.split(":");
|
|
16
|
+
if (params.length > 1 && params[0]) return {
|
|
17
|
+
file: params[0],
|
|
18
|
+
name: params[1]
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (param.includes("#")) {
|
|
22
|
+
const params = param.split("#");
|
|
23
|
+
if (params.length > 1 && params[0]) return {
|
|
24
|
+
file: params[0],
|
|
25
|
+
name: params[1]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return { file: param };
|
|
29
|
+
}
|
|
30
|
+
if (require_is_object.isObject(param)) return {
|
|
31
|
+
file: param.file,
|
|
32
|
+
name: param.name
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.parseTypeDefinition = parseTypeDefinition;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isObject } from "./type-checks/src/is-object.mjs";
|
|
2
|
+
import { isString } from "./type-checks/src/is-string.mjs";
|
|
3
|
+
import "./type-checks/src/index.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/parse-type-definition.mjs
|
|
6
|
+
/**
|
|
7
|
+
* Parse a type definition parameter into a {@link TypeDefinition} object
|
|
8
|
+
*
|
|
9
|
+
* @param param - The parameter to parse
|
|
10
|
+
* @returns The parsed type definition
|
|
11
|
+
*/
|
|
12
|
+
const parseTypeDefinition = (param) => {
|
|
13
|
+
if (isString(param)) {
|
|
14
|
+
if (param.includes(":")) {
|
|
15
|
+
const params = param.split(":");
|
|
16
|
+
if (params.length > 1 && params[0]) return {
|
|
17
|
+
file: params[0],
|
|
18
|
+
name: params[1]
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (param.includes("#")) {
|
|
22
|
+
const params = param.split("#");
|
|
23
|
+
if (params.length > 1 && params[0]) return {
|
|
24
|
+
file: params[0],
|
|
25
|
+
name: params[1]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return { file: param };
|
|
29
|
+
}
|
|
30
|
+
if (isObject(param)) return {
|
|
31
|
+
file: param.file,
|
|
32
|
+
name: param.name
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { parseTypeDefinition };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/to-array.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Convert `Arrayable<T>` to `Array<T>`
|
|
5
|
+
*
|
|
6
|
+
* @param array - The `Arrayable<T>` to convert
|
|
7
|
+
* @returns An `Array<T>` containing the elements of the input
|
|
8
|
+
*/
|
|
9
|
+
function toArray(array) {
|
|
10
|
+
array = array ?? [];
|
|
11
|
+
return Array.isArray(array) ? array : [array];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.toArray = toArray;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/to-array.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Convert `Arrayable<T>` to `Array<T>`
|
|
4
|
+
*
|
|
5
|
+
* @param array - The `Arrayable<T>` to convert
|
|
6
|
+
* @returns An `Array<T>` containing the elements of the input
|
|
7
|
+
*/
|
|
8
|
+
function toArray(array) {
|
|
9
|
+
array = array ?? [];
|
|
10
|
+
return Array.isArray(array) ? array : [array];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { toArray };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/get-object-tag.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Gets the `toStringTag` of `obj`.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The obj to query.
|
|
7
|
+
* @returns Returns the `toStringTag`.
|
|
8
|
+
*/
|
|
9
|
+
const getObjectTag = (value) => {
|
|
10
|
+
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
11
|
+
return Object.prototype.toString.call(value);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.getObjectTag = getObjectTag;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/get-object-tag.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Gets the `toStringTag` of `obj`.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The obj to query.
|
|
6
|
+
* @returns Returns the `toStringTag`.
|
|
7
|
+
*/
|
|
8
|
+
const getObjectTag = (value) => {
|
|
9
|
+
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
10
|
+
return Object.prototype.toString.call(value);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getObjectTag };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const require_is_plain_object = require('./is-plain-object.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-object.mjs
|
|
4
|
+
/**
|
|
5
|
+
* Check if the provided value's type is `Object`
|
|
6
|
+
*
|
|
7
|
+
* @param value - The value to type check
|
|
8
|
+
* @returns An indicator specifying if the value provided is of type `Object`
|
|
9
|
+
*/
|
|
10
|
+
const isObject = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
return typeof value === "object" || Boolean(value) && value?.constructor === Object || require_is_plain_object.isPlainObject(value);
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.isObject = isObject;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isPlainObject } from "./is-plain-object.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-object.mjs
|
|
4
|
+
/**
|
|
5
|
+
* Check if the provided value's type is `Object`
|
|
6
|
+
*
|
|
7
|
+
* @param value - The value to type check
|
|
8
|
+
* @returns An indicator specifying if the value provided is of type `Object`
|
|
9
|
+
*/
|
|
10
|
+
const isObject = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { isObject };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const require_get_object_tag = require('./get-object-tag.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-plain-object.mjs
|
|
4
|
+
/**
|
|
5
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
6
|
+
* and has a `typeof` result of "object".
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* isObjectLike({})
|
|
11
|
+
* // => true
|
|
12
|
+
*
|
|
13
|
+
* isObjectLike([1, 2, 3])
|
|
14
|
+
* // => true
|
|
15
|
+
*
|
|
16
|
+
* isObjectLike(Function)
|
|
17
|
+
* // => false
|
|
18
|
+
*
|
|
19
|
+
* isObjectLike(null)
|
|
20
|
+
* // => false
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param value - The value to check.
|
|
24
|
+
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
25
|
+
*/
|
|
26
|
+
const isObjectLike = (obj) => {
|
|
27
|
+
return typeof obj === "object" && obj !== null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* function Foo() {
|
|
35
|
+
* this.a = 1
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* isPlainObject(new Foo)
|
|
39
|
+
* // => false
|
|
40
|
+
*
|
|
41
|
+
* isPlainObject([1, 2, 3])
|
|
42
|
+
* // => false
|
|
43
|
+
*
|
|
44
|
+
* isPlainObject({ 'x': 0, 'y': 0 })
|
|
45
|
+
* // => true
|
|
46
|
+
*
|
|
47
|
+
* isPlainObject(Object.create(null))
|
|
48
|
+
* // => true
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param obj - The value to check.
|
|
52
|
+
* @returns Returns `true` if `obj` is a plain object, else `false`.
|
|
53
|
+
*/
|
|
54
|
+
const isPlainObject = (obj) => {
|
|
55
|
+
if (!isObjectLike(obj) || require_get_object_tag.getObjectTag(obj) !== "[object Object]") return false;
|
|
56
|
+
if (Object.getPrototypeOf(obj) === null) return true;
|
|
57
|
+
let proto = obj;
|
|
58
|
+
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
59
|
+
return Object.getPrototypeOf(obj) === proto;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.isPlainObject = isPlainObject;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getObjectTag } from "./get-object-tag.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-plain-object.mjs
|
|
4
|
+
/**
|
|
5
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
6
|
+
* and has a `typeof` result of "object".
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* isObjectLike({})
|
|
11
|
+
* // => true
|
|
12
|
+
*
|
|
13
|
+
* isObjectLike([1, 2, 3])
|
|
14
|
+
* // => true
|
|
15
|
+
*
|
|
16
|
+
* isObjectLike(Function)
|
|
17
|
+
* // => false
|
|
18
|
+
*
|
|
19
|
+
* isObjectLike(null)
|
|
20
|
+
* // => false
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param value - The value to check.
|
|
24
|
+
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
25
|
+
*/
|
|
26
|
+
const isObjectLike = (obj) => {
|
|
27
|
+
return typeof obj === "object" && obj !== null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* function Foo() {
|
|
35
|
+
* this.a = 1
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* isPlainObject(new Foo)
|
|
39
|
+
* // => false
|
|
40
|
+
*
|
|
41
|
+
* isPlainObject([1, 2, 3])
|
|
42
|
+
* // => false
|
|
43
|
+
*
|
|
44
|
+
* isPlainObject({ 'x': 0, 'y': 0 })
|
|
45
|
+
* // => true
|
|
46
|
+
*
|
|
47
|
+
* isPlainObject(Object.create(null))
|
|
48
|
+
* // => true
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param obj - The value to check.
|
|
52
|
+
* @returns Returns `true` if `obj` is a plain object, else `false`.
|
|
53
|
+
*/
|
|
54
|
+
const isPlainObject = (obj) => {
|
|
55
|
+
if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") return false;
|
|
56
|
+
if (Object.getPrototypeOf(obj) === null) return true;
|
|
57
|
+
let proto = obj;
|
|
58
|
+
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
59
|
+
return Object.getPrototypeOf(obj) === proto;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { isPlainObject };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-string.mjs
|
|
3
|
+
const isString = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
return typeof value === "string";
|
|
6
|
+
} catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.isString = isString;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@stryke+convert@0.6.34/node_modules/@stryke/convert/dist/type-checks/src/is-string.mjs
|
|
2
|
+
const isString = (value) => {
|
|
3
|
+
try {
|
|
4
|
+
return typeof value === "string";
|
|
5
|
+
} catch {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { isString };
|