@take-out/scripts 0.4.1 → 0.4.3-1775691786096

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@take-out/scripts",
3
- "version": "0.4.1",
3
+ "version": "0.4.3-1775691786096",
4
4
  "type": "module",
5
5
  "main": "./src/cmd.ts",
6
6
  "sideEffects": false,
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@clack/prompts": "^0.8.2",
32
- "@take-out/helpers": "0.4.1",
33
- "@take-out/run": "0.4.1",
32
+ "@take-out/helpers": "0.4.3-1775691786096",
33
+ "@take-out/run": "0.4.3-1775691786096",
34
34
  "picocolors": "^1.1.1"
35
35
  }
36
36
  }
package/src/env-update.ts CHANGED
@@ -24,33 +24,27 @@ await cmd`sync environment variables from src/env.ts to matching files`
24
24
  .run(async ({ args }) => {
25
25
  // import env var definitions from src/env.ts (the single source of truth)
26
26
  const envModule = await import(path.resolve('src/env.ts'))
27
- const envVars = envModule.envVars as Record<string, string | symbol>
28
- const envDeps = (envModule.envDeps || {}) as Record<string, string>
27
+ const production = envModule.production as Record<string, string | symbol>
28
+ const versions = (envModule.versions || {}) as Record<string, string>
29
29
 
30
- if (!envVars || typeof envVars !== 'object') {
31
- console.error('no envVars export found in src/env.ts')
30
+ if (!production || typeof production !== 'object') {
31
+ console.error('no production export found in src/env.ts')
32
32
  process.exit(1)
33
33
  }
34
34
 
35
35
  // the expected symbol from @take-out/env
36
36
  const expectedSymbol = Symbol.for('take-out/env/expected')
37
37
 
38
- // resolve dep versions from package.json dependencies
38
+ // merge resolved versions into the var registry
39
39
  const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
40
- const depResolved: Record<string, string> = {}
41
- for (const [key, depName] of Object.entries(envDeps)) {
42
- const version = packageJson.dependencies?.[depName]?.replace(/^[\^~]/, '')
43
- if (version) {
44
- depResolved[key] = version
45
- // add dep-resolved vars to envVars with resolved value
46
- envVars[key] = version
47
- }
40
+ const depResolved = { ...versions }
41
+ for (const [key, value] of Object.entries(versions)) {
42
+ production[key] = value
48
43
  }
49
44
 
50
- // normalize envVars: expected symbol → true (required), string → string
51
- // for compatibility with strategy functions
45
+ // normalize: expected symbol → required, string → defaultValue
52
46
  type EnvEntry = { key: string; required: boolean; defaultValue: string }
53
- const entries: EnvEntry[] = Object.entries(envVars)
47
+ const entries: EnvEntry[] = Object.entries(production)
54
48
  .map(([key, value]) => ({
55
49
  key,
56
50
  required: value === expectedSymbol,
@@ -9,9 +9,25 @@ export async function loadEnv(
9
9
  // loads env into process.env
10
10
  await vxrnLoadEnv(environment)
11
11
 
12
- // import src/env.ts to get the env config applied (side effect: populates process.env)
13
- const envModule = await import(join(process.cwd(), 'src/env.ts'))
14
- const Environment = envModule.server || {}
12
+ const previousMode = process.env.TAKEOUT_ENV_MODE
13
+ if (environment === 'development' || environment === 'production') {
14
+ process.env.TAKEOUT_ENV_MODE = environment
15
+ } else {
16
+ delete process.env.TAKEOUT_ENV_MODE
17
+ }
18
+
19
+ let Environment: Record<string, string>
20
+ try {
21
+ // import src/env.ts to get the env config applied (side effect: populates process.env)
22
+ const envModule = await import(join(process.cwd(), 'src/env.ts'))
23
+ Environment = envModule.server || {}
24
+ } finally {
25
+ if (previousMode === undefined) {
26
+ delete process.env.TAKEOUT_ENV_MODE
27
+ } else {
28
+ process.env.TAKEOUT_ENV_MODE = previousMode
29
+ }
30
+ }
15
31
 
16
32
  // validate
17
33
  for (const key in Environment) {
@@ -22,6 +22,10 @@ export async function getTestEnv() {
22
22
  ...serverEnvFallback,
23
23
  ...devEnv,
24
24
  CI: 'true',
25
+ // Child test processes may import src/env.ts directly. Keep them pinned to
26
+ // development mode even when the parent release flow started from
27
+ // production-flavored env.
28
+ TAKEOUT_ENV_MODE: 'development',
25
29
  ...(!process.env.DEBUG_BACKEND && {
26
30
  ZERO_LOG_LEVEL: 'warn',
27
31
  }),