@agnostack/env 2.0.0-canary.2 → 2.0.0-canary.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [2.0.0-canary.3](https://github.com/[secure]/env/compare/v2.0.0-canary.2...v2.0.0-canary.3) (2026-08-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * updated to test pin appName derivation on the first hyphen and override ([d83c6b5](https://github.com/[secure]/env/commit/d83c6b5c41d2a4b7135bfa8dd7dad65b083f2805))
7
+
8
+
9
+ ### Features
10
+
11
+ * return argEntries so callers can forward what they did not consume ([b9dba14](https://github.com/[secure]/env/commit/b9dba140330bb2684f91911512556bbcd355942a))
12
+
1
13
  # [2.0.0-canary.2](https://github.com/[secure]/env/compare/v2.0.0-canary.1...v2.0.0-canary.2) (2026-08-16)
2
14
 
3
15
 
package/dist/env.d.ts CHANGED
@@ -10,21 +10,21 @@ export function lowerKeyValidator(envKey: string): boolean;
10
10
  export function publicKeyValidator(envKey: string): boolean;
11
11
  export function cleanLowerEnv(_env: Record<string, string | undefined> | undefined, keyValidator?: (envKey: string) => boolean): Record<string, string | undefined>;
12
12
  export function cleanPublicEnv(_env: Record<string, string | undefined> | undefined, keyValidator?: (envKey: string) => boolean): Record<string, string | undefined>;
13
- export function parseEnvData(_env?: NodeJS.ProcessEnv): {
13
+ export function parseEnvData(_env?: Record<string, string | undefined>): {
14
+ args: string[];
14
15
  env: Record<string, string> & {
15
16
  ENVIRONMENT: string;
16
17
  };
17
18
  nextEnv: Record<string, string | undefined>;
18
19
  publicEnv: Record<string, string | undefined>;
19
20
  stringifiedEnv: Record<string, string>;
20
- argParams: {
21
- [x: string]: string | undefined;
22
- };
23
- params: {
24
- [x: string]: string | undefined;
25
- ENVIRONMENT: string;
26
- };
27
- args: string[];
21
+ argEntries: {
22
+ arg: string;
23
+ param: string;
24
+ value: string | undefined;
25
+ }[];
26
+ argParams: Record<string, string | undefined>;
27
+ params: Record<string, string | undefined>;
28
28
  };
29
29
  export function getPublicEnvValue(publicEnv: Record<string, string | undefined> | undefined, key: string): string | undefined;
30
30
  export function replaceEnvTemplate(replaceable: unknown, { env: _env, template, callback, }?: {
package/dist/env.js CHANGED
@@ -61,6 +61,39 @@ exports.cleanLowerEnv = cleanLowerEnv;
61
61
  */
62
62
  const cleanPublicEnv = (_env, keyValidator = exports.publicKeyValidator) => (cleanEnv(_env, keyValidator));
63
63
  exports.cleanPublicEnv = cleanPublicEnv;
64
+ /**
65
+ * The one place argv and the ambient env are read together, so a caller gets both from a single
66
+ * call rather than parsing argv itself.
67
+ *
68
+ * ENVIRONMENT is resolved rather than trusted: an explicit `ENVIRONMENT` wins, otherwise the first
69
+ * non-empty of SITE_ENV, BUILD_ENV, NODE_ENV, falling back to 'development'.
70
+ *
71
+ * ⚠️ The argv split is by FORM, not by meaning. `--key=value` becomes an `argParams` entry; a
72
+ * valueless `--flag` stays a string in `args`, which also still holds `process.argv[0]` (the node
73
+ * binary) and `[1]` (the script path). A caller reading positionals must skip those two, and one
74
+ * reading bare flags must look in `args` rather than `argParams`.
75
+ *
76
+ * `argEntries` is the third view: every argument in order — `arg` as typed, `param` and `value`
77
+ * already split out — so a
78
+ * caller can forward what it did not consume without re-deriving it. An ARRAY rather than a map
79
+ * because repeats are meaningful — `--context=a=1 --context=b=2` is two entries, and keying them
80
+ * would silently keep only the last.
81
+ *
82
+ * `stringifiedEnv` is a MAP, not a string — each value JSON-stringified, which is the shape
83
+ * webpack's DefinePlugin wants.
84
+ *
85
+ * @param {Record<string, string | undefined>} [_env] defaults to process.env
86
+ * @returns {{
87
+ * args: string[],
88
+ * env: Record<string, string> & { ENVIRONMENT: string },
89
+ * nextEnv: Record<string, string | undefined>,
90
+ * publicEnv: Record<string, string | undefined>,
91
+ * stringifiedEnv: Record<string, string>,
92
+ * argEntries: { arg: string, param: string, value: string | undefined }[],
93
+ * argParams: Record<string, string | undefined>,
94
+ * params: Record<string, string | undefined>,
95
+ * }}
96
+ */
64
97
  const parseEnvData = (_env = process.env) => {
65
98
  var _a;
66
99
  const { ENVIRONMENT, SITE_ENV, BUILD_ENV, NODE_ENV } = _env;
@@ -73,7 +106,10 @@ const parseEnvData = (_env = process.env) => {
73
106
  const mergedEnv = Object.assign(Object.assign({}, _env), {
74
107
  // NOTE: intentionally giving precedence to ENVIRONMENT
75
108
  ENVIRONMENT: ENVIRONMENT || _environment });
76
- const _b = process.argv.reduce(({ args: _args, argParams: _argParams, }, arg) => {
109
+ // NOTE: One pass over argv building both halves of the split `args` collects every entry that
110
+ // carried no value (bare flags, positionals, and argv[0]/[1]), `argParams` every `key=value` one
111
+ // with its leading `--` stripped. An entry is never in both.
112
+ const _b = process.argv.reduce(({ args: _args, argParams: _argParams, argEntries: _argEntries, }, arg, index) => {
77
113
  var _a, _b, _c, _d, _e;
78
114
  // NOTE: split on the FIRST '=' only — everything after it is the value, verbatim.
79
115
  // Splitting on every '=' truncated any value that contained one, so `--context=env=prod`
@@ -87,6 +123,7 @@ const parseEnvData = (_env = process.env) => {
87
123
  return {
88
124
  args: _args,
89
125
  argParams: _argParams,
126
+ argEntries: _argEntries,
90
127
  };
91
128
  }
92
129
  /** @type {[string, string | undefined]} */
@@ -108,10 +145,20 @@ const parseEnvData = (_env = process.env) => {
108
145
  argParams: Object.assign(Object.assign({}, _argParams), (0, display_js_1.stringNotEmptyOnly)(value) && {
109
146
  [param]: value,
110
147
  }),
148
+ // NOTE: index 0 is the node binary and 1 the script path — never arguments, so neither
149
+ // reaches argEntries. That is what lets a caller forward `arg` without re-deriving which
150
+ // entries were real arguments.
151
+ argEntries: [
152
+ ..._argEntries,
153
+ ...(index >= 2) ? [{ arg, param, value }] : []
154
+ ],
111
155
  };
112
156
  }, {
113
157
  args: /** @type {string[]} */ ([]),
114
- argParams: /** @type {Record<string, string>} */ ({}),
158
+ // NOTE: `string | undefined` because the conditional spread below can widen it — seeding it
159
+ // as `Record<string, string>` made the accumulator and the callback's return disagree.
160
+ argParams: /** @type {Record<string, string | undefined>} */ ({}),
161
+ argEntries: /** @type {{ arg: string, param: string, value: string | undefined }[]} */ ([]),
115
162
  }), { argParams } = _b, output = __rest(_b, ["argParams"]);
116
163
  const nextEnv = cleanEnv(mergedEnv);
117
164
  const publicEnv = (0, exports.cleanPublicEnv)(mergedEnv);
package/dist/esm/env.js CHANGED
@@ -53,6 +53,39 @@ export const cleanLowerEnv = (_env, keyValidator = lowerKeyValidator) => (cleanE
53
53
  * @returns {Record<string, string | undefined>}
54
54
  */
55
55
  export const cleanPublicEnv = (_env, keyValidator = publicKeyValidator) => (cleanEnv(_env, keyValidator));
56
+ /**
57
+ * The one place argv and the ambient env are read together, so a caller gets both from a single
58
+ * call rather than parsing argv itself.
59
+ *
60
+ * ENVIRONMENT is resolved rather than trusted: an explicit `ENVIRONMENT` wins, otherwise the first
61
+ * non-empty of SITE_ENV, BUILD_ENV, NODE_ENV, falling back to 'development'.
62
+ *
63
+ * ⚠️ The argv split is by FORM, not by meaning. `--key=value` becomes an `argParams` entry; a
64
+ * valueless `--flag` stays a string in `args`, which also still holds `process.argv[0]` (the node
65
+ * binary) and `[1]` (the script path). A caller reading positionals must skip those two, and one
66
+ * reading bare flags must look in `args` rather than `argParams`.
67
+ *
68
+ * `argEntries` is the third view: every argument in order — `arg` as typed, `param` and `value`
69
+ * already split out — so a
70
+ * caller can forward what it did not consume without re-deriving it. An ARRAY rather than a map
71
+ * because repeats are meaningful — `--context=a=1 --context=b=2` is two entries, and keying them
72
+ * would silently keep only the last.
73
+ *
74
+ * `stringifiedEnv` is a MAP, not a string — each value JSON-stringified, which is the shape
75
+ * webpack's DefinePlugin wants.
76
+ *
77
+ * @param {Record<string, string | undefined>} [_env] defaults to process.env
78
+ * @returns {{
79
+ * args: string[],
80
+ * env: Record<string, string> & { ENVIRONMENT: string },
81
+ * nextEnv: Record<string, string | undefined>,
82
+ * publicEnv: Record<string, string | undefined>,
83
+ * stringifiedEnv: Record<string, string>,
84
+ * argEntries: { arg: string, param: string, value: string | undefined }[],
85
+ * argParams: Record<string, string | undefined>,
86
+ * params: Record<string, string | undefined>,
87
+ * }}
88
+ */
56
89
  export const parseEnvData = (_env = process.env) => {
57
90
  var _a;
58
91
  const { ENVIRONMENT, SITE_ENV, BUILD_ENV, NODE_ENV } = _env;
@@ -65,7 +98,10 @@ export const parseEnvData = (_env = process.env) => {
65
98
  const mergedEnv = Object.assign(Object.assign({}, _env), {
66
99
  // NOTE: intentionally giving precedence to ENVIRONMENT
67
100
  ENVIRONMENT: ENVIRONMENT || _environment });
68
- const _b = process.argv.reduce(({ args: _args, argParams: _argParams, }, arg) => {
101
+ // NOTE: One pass over argv building both halves of the split `args` collects every entry that
102
+ // carried no value (bare flags, positionals, and argv[0]/[1]), `argParams` every `key=value` one
103
+ // with its leading `--` stripped. An entry is never in both.
104
+ const _b = process.argv.reduce(({ args: _args, argParams: _argParams, argEntries: _argEntries, }, arg, index) => {
69
105
  var _a, _b, _c, _d, _e;
70
106
  // NOTE: split on the FIRST '=' only — everything after it is the value, verbatim.
71
107
  // Splitting on every '=' truncated any value that contained one, so `--context=env=prod`
@@ -79,6 +115,7 @@ export const parseEnvData = (_env = process.env) => {
79
115
  return {
80
116
  args: _args,
81
117
  argParams: _argParams,
118
+ argEntries: _argEntries,
82
119
  };
83
120
  }
84
121
  /** @type {[string, string | undefined]} */
@@ -100,10 +137,20 @@ export const parseEnvData = (_env = process.env) => {
100
137
  argParams: Object.assign(Object.assign({}, _argParams), stringNotEmptyOnly(value) && {
101
138
  [param]: value,
102
139
  }),
140
+ // NOTE: index 0 is the node binary and 1 the script path — never arguments, so neither
141
+ // reaches argEntries. That is what lets a caller forward `arg` without re-deriving which
142
+ // entries were real arguments.
143
+ argEntries: [
144
+ ..._argEntries,
145
+ ...(index >= 2) ? [{ arg, param, value }] : []
146
+ ],
103
147
  };
104
148
  }, {
105
149
  args: /** @type {string[]} */ ([]),
106
- argParams: /** @type {Record<string, string>} */ ({}),
150
+ // NOTE: `string | undefined` because the conditional spread below can widen it — seeding it
151
+ // as `Record<string, string>` made the accumulator and the callback's return disagree.
152
+ argParams: /** @type {Record<string, string | undefined>} */ ({}),
153
+ argEntries: /** @type {{ arg: string, param: string, value: string | undefined }[]} */ ([]),
107
154
  }), { argParams } = _b, output = __rest(_b, ["argParams"]);
108
155
  const nextEnv = cleanEnv(mergedEnv);
109
156
  const publicEnv = cleanPublicEnv(mergedEnv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agnostack/env",
3
- "version": "2.0.0-canary.2",
3
+ "version": "2.0.0-canary.3",
4
4
  "author": "agnoStack Dev <developers@agnostack.com> (https://agnostack.com)",
5
5
  "owner": "agnoStack",
6
6
  "description": "Please contact agnoStack via info@agnostack.com for any questions",