@take-out/scripts 0.1.2 → 0.1.4
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.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/run.ts",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@clack/prompts": "^0.8.2",
|
|
32
|
-
"@take-out/helpers": "0.1.
|
|
32
|
+
"@take-out/helpers": "0.1.4",
|
|
33
33
|
"picocolors": "^1.1.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
package/src/env-update.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import fs from 'node:fs'
|
|
4
4
|
|
|
5
5
|
import { cmd } from './cmd'
|
|
6
|
+
import { resolveDepVersion } from './helpers/resolve-dep-version'
|
|
6
7
|
|
|
7
8
|
await cmd`sync environment variables from package.json to CI and server configs`.run(
|
|
8
9
|
async () => {
|
|
@@ -43,8 +44,14 @@ await cmd`sync environment variables from package.json to CI and server configs`
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
const indent = ` `
|
|
46
|
-
const envSection = Object.
|
|
47
|
-
.map((key) =>
|
|
47
|
+
const envSection = Object.entries(envVars)
|
|
48
|
+
.map(([key, value]) => {
|
|
49
|
+
const resolved = resolveDepVersion(value, packageJson.dependencies)
|
|
50
|
+
if (resolved) {
|
|
51
|
+
return `${indent}${key}: \${{ secrets.${key} || '${resolved}' }}`
|
|
52
|
+
}
|
|
53
|
+
return `${indent}${key}: \${{ secrets.${key} }}`
|
|
54
|
+
})
|
|
48
55
|
.join('\n')
|
|
49
56
|
|
|
50
57
|
const newDeployYml = replaceYamlSection(deployYml, envSection, { indent })
|
|
@@ -3,14 +3,9 @@
|
|
|
3
3
|
import fs from 'node:fs'
|
|
4
4
|
|
|
5
5
|
import { cmd } from './cmd'
|
|
6
|
+
import { resolveDepVersion } from './helpers/resolve-dep-version'
|
|
6
7
|
|
|
7
8
|
await cmd`sync auto-generated env vars to local .env file`.run(async ({ path }) => {
|
|
8
|
-
// skip in CI environments
|
|
9
|
-
if (process.env.CI === 'true') {
|
|
10
|
-
console.info('Skipping bootstrap in CI environment')
|
|
11
|
-
process.exit(0)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
9
|
const ENV_PATH = path.join(process.cwd(), '.env')
|
|
15
10
|
const ENV_BACKUP_PATH = path.join(process.cwd(), '.env.backup')
|
|
16
11
|
const ENV_TEMP_PATH = path.join(process.cwd(), '.env.tmp')
|
|
@@ -32,15 +27,13 @@ await cmd`sync auto-generated env vars to local .env file`.run(async ({ path })
|
|
|
32
27
|
const lines: string[] = [BEGIN_MARKER, `# Generated at: ${new Date().toISOString()}`]
|
|
33
28
|
|
|
34
29
|
for (const [key, value] of Object.entries(envVars)) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
console.warn(`Could not resolve dependency version for ${depName}`)
|
|
43
|
-
}
|
|
30
|
+
const depVersion = resolveDepVersion(value, packageJson.dependencies)
|
|
31
|
+
if (depVersion) {
|
|
32
|
+
lines.push(`${key}=${depVersion}`)
|
|
33
|
+
} else if (typeof value === 'string' && value.startsWith('$dep:')) {
|
|
34
|
+
console.warn(
|
|
35
|
+
`Could not resolve dependency version for ${value.slice('$dep:'.length)}`
|
|
36
|
+
)
|
|
44
37
|
} else if (typeof value === 'string' && value !== '') {
|
|
45
38
|
// non-empty string default
|
|
46
39
|
lines.push(`${key}=${value}`)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* resolves a `$dep:package-name` value to the installed version from dependencies
|
|
3
|
+
*/
|
|
4
|
+
export function resolveDepVersion(
|
|
5
|
+
value: string | boolean,
|
|
6
|
+
dependencies: Record<string, string> | undefined
|
|
7
|
+
): string | undefined {
|
|
8
|
+
if (typeof value !== 'string' || !value.startsWith('$dep:')) return undefined
|
|
9
|
+
const depName = value.slice('$dep:'.length)
|
|
10
|
+
return dependencies?.[depName]?.replace(/^[\^~]/, '')
|
|
11
|
+
}
|
package/src/up.ts
CHANGED
|
@@ -429,7 +429,7 @@ await cmd`upgrade packages by name or pattern`
|
|
|
429
429
|
// special handling for zero - update ZERO_VERSION in .env
|
|
430
430
|
if (packagePatterns.includes('@rocicorp/zero')) {
|
|
431
431
|
console.info('\n🔄 Updating local env for Zero...')
|
|
432
|
-
await $`bun tko run
|
|
432
|
+
await $`bun tko run generate-env`
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
console.info('\n🎉 Dependency update complete!')
|