@take-out/scripts 0.0.91 → 0.0.93

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.0.91",
3
+ "version": "0.0.93",
4
4
  "type": "module",
5
5
  "main": "./src/run.ts",
6
6
  "sideEffects": false,
@@ -28,7 +28,7 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@take-out/helpers": "0.0.79"
31
+ "@take-out/helpers": "0.0.93"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "vxrn": "^1.4.15"
@@ -1,3 +1,4 @@
1
+ import { existsSync } from 'node:fs'
1
2
  import { join } from 'node:path'
2
3
 
3
4
  import { loadEnv as vxrnLoadEnv } from 'vxrn/loadEnv'
@@ -9,9 +10,9 @@ export async function loadEnv(
9
10
  // loads env into process.env
10
11
  await vxrnLoadEnv(environment)
11
12
 
12
- const Environment = await import(
13
- options?.envPath || join(process.cwd(), 'src/server/env-server.ts')
14
- )
13
+ const envPath = options?.envPath || resolveEnvServerPath()
14
+
15
+ const Environment = await import(envPath)
15
16
 
16
17
  // validate
17
18
  for (const key in Environment) {
@@ -25,3 +26,15 @@ export async function loadEnv(
25
26
 
26
27
  return Environment
27
28
  }
29
+
30
+ function resolveEnvServerPath(): string {
31
+ const candidates = ['src/constants/env-server.ts', 'src/server/env-server.ts']
32
+ for (const candidate of candidates) {
33
+ const full = join(process.cwd(), candidate)
34
+ if (existsSync(full)) {
35
+ return full
36
+ }
37
+ }
38
+ // fall back to first candidate for error message
39
+ return join(process.cwd(), 'src/constants/env-server.ts')
40
+ }
@@ -1,3 +1,4 @@
1
+ import { existsSync } from 'node:fs'
1
2
  import { join } from 'node:path'
2
3
 
3
4
  import { loadEnv } from './env-load'
@@ -8,7 +9,10 @@ export async function getTestEnv() {
8
9
  const zeroVersion = getZeroVersion()
9
10
  const dockerHost = getDockerHost()
10
11
  const devEnv = await loadEnv('development')
11
- const serverEnvFallback = await import(join(process.cwd(), 'src/server/env-server'))
12
+ const envPath = ['src/constants/env-server', 'src/server/env-server']
13
+ .map((p) => join(process.cwd(), p))
14
+ .find((p) => existsSync(p + '.ts')) || join(process.cwd(), 'src/constants/env-server')
15
+ const serverEnvFallback = await import(envPath)
12
16
 
13
17
  // ports come from VITE_PORT_* in .env.development (loaded by loadEnv)
14
18
  const dbPort = process.env.VITE_PORT_POSTGRES || '5433'
package/src/release.ts CHANGED
@@ -179,11 +179,8 @@ async function mainRelease() {
179
179
  const nextDeps = next[field]
180
180
  if (!nextDeps) continue
181
181
  for (const depName in nextDeps) {
182
- // only update non-workspace internal dependencies
183
- if (!nextDeps[depName].startsWith('workspace:')) {
184
- if (allPackageJsons.some((p) => p.name === depName)) {
185
- nextDeps[depName] = nextVersion
186
- }
182
+ if (allPackageJsons.some((p) => p.name === depName)) {
183
+ nextDeps[depName] = nextVersion
187
184
  }
188
185
  }
189
186
  }
@@ -241,6 +238,31 @@ async function mainRelease() {
241
238
 
242
239
  console.info(`✅ ${dryRun ? '[dry-run] ' : ''}Published\n`)
243
240
 
241
+ // restore workspace:* protocols after publishing
242
+ if (!dryRun) {
243
+ await Promise.all(
244
+ allPackageJsons.map(async ({ json, path }) => {
245
+ const current = await fs.readJSON(path)
246
+ for (const field of [
247
+ 'dependencies',
248
+ 'devDependencies',
249
+ 'optionalDependencies',
250
+ 'peerDependencies',
251
+ ]) {
252
+ const origDeps = json[field]
253
+ const currentDeps = current[field]
254
+ if (!origDeps || !currentDeps) continue
255
+ for (const depName in origDeps) {
256
+ if (origDeps[depName].startsWith('workspace:') && currentDeps[depName]) {
257
+ currentDeps[depName] = origDeps[depName]
258
+ }
259
+ }
260
+ }
261
+ await writeJSON(path, current, { spaces: 2 })
262
+ })
263
+ )
264
+ }
265
+
244
266
  // revert version changes after dry-run
245
267
  if (dryRun) {
246
268
  await run(`git checkout -- packages/*/package.json`, { silent: true })