tangled
alpha
login
or
join now
danabra.mov
/
typelex
56
fork
atom
An experimental TypeSpec syntax for Lexicon
56
fork
atom
overview
issues
1
pulls
2
pipelines
yeah
danabra.mov
5 months ago
e45d44af
03aabfc6
+117
2 changed files
expand all
collapse all
unified
split
packages
website
package.json
scripts
publish-all.sh
+1
packages/website/package.json
···
1
1
{
2
2
"name": "website",
3
3
"type": "module",
4
4
+
"private": true,
4
5
"version": "0.0.1",
5
6
"scripts": {
6
7
"dev": "astro dev",
+116
scripts/publish-all.sh
···
1
1
+
#!/bin/bash
2
2
+
set -e
3
3
+
4
4
+
# Usage: ./scripts/publish-all.sh <version>
5
5
+
# Example: ./scripts/publish-all.sh 0.4.0
6
6
+
7
7
+
if [ -z "$1" ]; then
8
8
+
echo "Error: Version argument required"
9
9
+
echo "Usage: ./scripts/publish-all.sh <version>"
10
10
+
echo "Example: ./scripts/publish-all.sh 0.4.0"
11
11
+
exit 1
12
12
+
fi
13
13
+
14
14
+
VERSION="$1"
15
15
+
16
16
+
# Validate version format (basic semver check)
17
17
+
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
18
18
+
echo "Error: Invalid version format. Use semver format (e.g., 0.4.0 or 0.4.0-beta.1)"
19
19
+
exit 1
20
20
+
fi
21
21
+
22
22
+
echo "📦 Publishing all packages at version $VERSION"
23
23
+
echo ""
24
24
+
25
25
+
# Get the root directory
26
26
+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
27
27
+
cd "$ROOT_DIR"
28
28
+
29
29
+
# Find all package.json files in packages/*
30
30
+
ALL_PACKAGES=($(find packages -maxdepth 2 -name "package.json" -not -path "*/node_modules/*" | sort))
31
31
+
32
32
+
# Filter out private packages
33
33
+
PACKAGES=()
34
34
+
for pkg in "${ALL_PACKAGES[@]}"; do
35
35
+
IS_PRIVATE=$(node -p "require('./$pkg').private || false")
36
36
+
if [ "$IS_PRIVATE" != "true" ]; then
37
37
+
PACKAGES+=("$pkg")
38
38
+
fi
39
39
+
done
40
40
+
41
41
+
if [ ${#PACKAGES[@]} -eq 0 ]; then
42
42
+
echo "Error: No publishable packages found in packages/"
43
43
+
exit 1
44
44
+
fi
45
45
+
46
46
+
echo "Found ${#PACKAGES[@]} publishable packages:"
47
47
+
for pkg in "${PACKAGES[@]}"; do
48
48
+
PKG_NAME=$(node -p "require('./$pkg').name")
49
49
+
echo " - $PKG_NAME"
50
50
+
done
51
51
+
echo ""
52
52
+
53
53
+
# Update all package.json files with the new version
54
54
+
echo "🔄 Updating versions in all packages..."
55
55
+
for pkg in "${PACKAGES[@]}"; do
56
56
+
PKG_DIR=$(dirname "$pkg")
57
57
+
PKG_NAME=$(node -p "require('./$pkg').name")
58
58
+
59
59
+
echo " Updating $PKG_NAME..."
60
60
+
61
61
+
# Update version
62
62
+
node -e "
63
63
+
const fs = require('fs');
64
64
+
const path = '$pkg';
65
65
+
const pkg = require('./' + path);
66
66
+
pkg.version = '$VERSION';
67
67
+
68
68
+
// Helper to preserve semver prefix (^, ~, etc.) and workspace: protocol
69
69
+
function updateVersion(currentVersion, newVersion) {
70
70
+
// Preserve workspace: protocol for monorepo
71
71
+
if (currentVersion.startsWith('workspace:')) {
72
72
+
return currentVersion;
73
73
+
}
74
74
+
// Preserve semver prefix
75
75
+
const match = currentVersion.match(/^([~^>=<]*)(.*)$/);
76
76
+
if (match) {
77
77
+
return match[1] + newVersion;
78
78
+
}
79
79
+
return newVersion;
80
80
+
}
81
81
+
82
82
+
// Helper to update dependencies
83
83
+
function updateDeps(deps) {
84
84
+
if (!deps) return;
85
85
+
for (const dep in deps) {
86
86
+
if (dep.startsWith('@typelex/')) {
87
87
+
deps[dep] = updateVersion(deps[dep], '$VERSION');
88
88
+
}
89
89
+
}
90
90
+
}
91
91
+
92
92
+
updateDeps(pkg.dependencies);
93
93
+
updateDeps(pkg.devDependencies);
94
94
+
updateDeps(pkg.peerDependencies);
95
95
+
96
96
+
fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n');
97
97
+
"
98
98
+
done
99
99
+
100
100
+
echo ""
101
101
+
echo "✅ All versions updated to $VERSION"
102
102
+
echo ""
103
103
+
104
104
+
echo ""
105
105
+
echo "✅ Dry run complete! Version updates have been applied."
106
106
+
echo ""
107
107
+
echo "📋 Updated packages:"
108
108
+
for pkg in "${PACKAGES[@]}"; do
109
109
+
PKG_NAME=$(node -p "require('./$pkg').name")
110
110
+
echo " - $PKG_NAME@$VERSION"
111
111
+
done
112
112
+
echo ""
113
113
+
echo "💡 Review the changes, then run with actual publishing enabled."
114
114
+
echo ""
115
115
+
echo "🚨 Publishing is currently disabled (dry-run mode)"
116
116
+
echo " To enable publishing, edit scripts/publish-all.sh and uncomment the publish section"